generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Merge two scripts.

Previous Thread :: Next Thread 
CrazyMe13 is not online. CrazyMe13
Joined: 07 Aug 2010
Total Posts: 45
24 Apr 2015 10:46 AM
So I tried everything I just can't merge those two scripts.

First one ( the main script of a weapon with knockback ) :


r = game:service("RunService")
debris = game:GetService("Debris")

local damage = 0


local slash_damage = 0
local lunge_damage = 0

sword = script.Parent.Handle
Tool = script.Parent



local SmashSound = Instance.new("Sound")
SmashSound.SoundId = "http://www.roblox.com/asset/?id=21433696"
SmashSound.Parent = sword
SmashSound.Volume = .7

local SmashSound2 = Instance.new("Sound")
SmashSound2.SoundId = "http://www.roblox.com/asset/?id=21433711"
SmashSound2.Parent = sword
SmashSound2.Volume = .7

local sounds = {SmashSound, SmashSound2}

local UnsheathSound = Instance.new("Sound")
UnsheathSound.SoundId = "rbxasset://sounds\\unsheath.wav"
UnsheathSound.Parent = sword
UnsheathSound.Volume = 0


function windforce(dir, victimTorso)
if (victimTorso.Parent:FindFirstChild("ForceField") ~= nil) then return end
if victimTorso:FindFirstChild("WindEffect") == nil then
local force = Instance.new("BodyVelocity")
force.Name = "WindEffect"
force.maxForce = Vector3.new(1e7, 1e7, 1e7)
force.P = 125
force.velocity = (dir * 100) + Vector3.new(0, 30,0)
force.Parent = victimTorso


game.Debris:AddItem(force, .10)


end
end



function blow(hit)
local humanoid = hit.Parent:findFirstChild("Humanoid")
local vCharacter = Tool.Parent
local vPlayer = game.Players:playerFromCharacter(vCharacter)
local hum = vCharacter:findFirstChild("Humanoid") -- non-nil if tool held by a character
if humanoid~=nil and humanoid ~= hum and hum ~= nil then
-- final check, make sure sword is in-hand

local right_arm = vCharacter:FindFirstChild("Right Arm")
if (right_arm ~= nil) then
local joint = right_arm:FindFirstChild("RightGrip")
if (joint ~= nil and (joint.Part0 == sword or joint.Part1 == sword)) then
tagHumanoid(humanoid, vPlayer)
humanoid:TakeDamage(damage)
local d = vCharacter.Torso.CFrame.lookVector
windforce(Vector3.new(d.x, d.y, d.z), hit.Parent.Torso)
wait(1)
untagHumanoid(humanoid)
end
end


end
end

function tagHumanoid(humanoid, player)
local creator_tag = Instance.new("ObjectValue")
creator_tag.Value = player
creator_tag.Name = "creator"
creator_tag.Parent = humanoid
end

function untagHumanoid(humanoid)
if humanoid ~= nil then
local tag = humanoid:findFirstChild("creator")
if tag ~= nil then
tag.Parent = nil
end
end
end


function attack()
damage = slash_damage

local s = sounds[math.random(1,#sounds)]
s.Pitch = .9 + (math.random() * .2)
s.Volume = .7 + (math.random() * .3)
s:Play()

local anim = Instance.new("StringValue")
anim.Name = "toolanim"
anim.Value = "Slash"
anim.Parent = Tool
end



function swordUp()
Tool.GripForward = Vector3.new(-1,0,0)
Tool.GripRight = Vector3.new(0,1,0)
Tool.GripUp = Vector3.new(0,0,1)
end

function swordOut()
Tool.GripForward = Vector3.new(0,0,1)
Tool.GripRight = Vector3.new(0,-1,0)
Tool.GripUp = Vector3.new(-1,0,0)
end

function swordAcross()
-- parry
end


Tool.Enabled = true
local last_attack = 0
function onActivated()

if not Tool.Enabled then
return
end

Tool.Enabled = false

local character = Tool.Parent;
local humanoid = character.Humanoid
if humanoid == nil then
print("Humanoid not found")
return
end


attack()



wait(.5)

Tool.Enabled = true
end


function onEquipped()
UnsheathSound:play()
end


script.Parent.Activated:connect(onActivated)
script.Parent.Equipped:connect(onEquipped)


connection = sword.Touched:connect(blow)


And the secound one ( a script that gives you a point everytime you knock someone out of the map ) :


game.Players.PlayerAdded:connect(function(plr)
plr.CharacterAdded:connect(function(char)
local stringVal = Instance.new("StringValue", char)
stringVal.Name = "Hit"
stringVal.Value = char.Name
local hum = char:WaitForChild("Humanoid")
hum.Died:connect(function()
if game.Players:FindFirstChild(stringVal.Val) then
game.Players[stringVal.Value].leaderstats.Points.Value = game.Players[stringVal.Value].leaderstats.Points.Value + 1
end
end)
end)
end)


Can I get a little bit of help?

Report Abuse
ExternalCode is not online. ExternalCode
Joined: 03 Jun 2014
Total Posts: 39
24 Apr 2015 11:58 AM
Second script revised -

game.Players.PlayerAdded:connect(function(plr)
plr.CharacterAdded:connect(function(char)
local stringVal = Instance.new("StringValue", char)
stringVal.Name = "Hit"
stringVal.Value = char.Name
local hum = char:WaitForChild("Humanoid")
hum.Died:connect(function()
if game.Players:FindFirstChild(stringVal.Val) then
game.Players[stringVal.Value].leaderstats.Points.Value = game.Players[stringVal.Value].leaderstats.Points.Value = leaderstats.Points.Value + 1
end
end)
end)
end)

Report Abuse
CrazyMe13 is not online. CrazyMe13
Joined: 07 Aug 2010
Total Posts: 45
24 Apr 2015 12:56 PM
Thanks for fixing it but where I am supposed to put it?
Report Abuse
CrazyMe13 is not online. CrazyMe13
Joined: 07 Aug 2010
Total Posts: 45
24 Apr 2015 01:57 PM
b
Report Abuse
Klink45 is not online. Klink45
Joined: 06 Jun 2011
Total Posts: 26054
24 Apr 2015 02:29 PM
Does it work fine in two scripts?
Report Abuse
CrazyMe13 is not online. CrazyMe13
Joined: 07 Aug 2010
Total Posts: 45
24 Apr 2015 02:39 PM
No, its not working at all.
Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
24 Apr 2015 02:40 PM
check your output and kyour script analysis
Report Abuse
Klink45 is not online. Klink45
Joined: 06 Jun 2011
Total Posts: 26054
24 Apr 2015 02:42 PM
Try this:

local r = game:service("RunService")
debris = game:GetService("Debris")

local damage = 0


local slash_damage = 0
local lunge_damage = 0

local sword = script.Parent.Handle
local Tool = script.Parent



local SmashSound = Instance.new("Sound")
SmashSound.SoundId = "http://www.roblox.com/asset/?id=21433696"
SmashSound.Parent = sword
SmashSound.Volume = .7

local SmashSound2 = Instance.new("Sound")
SmashSound2.SoundId = "http://www.roblox.com/asset/?id=21433711"
SmashSound2.Parent = sword
SmashSound2.Volume = .7

local sounds = {SmashSound, SmashSound2}

local UnsheathSound = Instance.new("Sound")
UnsheathSound.SoundId = "rbxasset://sounds\\unsheath.wav"
UnsheathSound.Parent = sword
UnsheathSound.Volume = 0


function windforce(dir, victimTorso)
if (victimTorso.Parent:FindFirstChild("ForceField") ~= nil) then return end
if victimTorso:FindFirstChild("WindEffect") == nil then
local force = Instance.new("BodyVelocity")
force.Name = "WindEffect"
force.maxForce = Vector3.new(1e7, 1e7, 1e7)
force.P = 125
force.velocity = (dir * 100) + Vector3.new(0, 30,0)
force.Parent = victimTorso
game.Players.PlayerAdded:connect(function(plr)
plr.CharacterAdded:connect(function(char)
local stringVal = Instance.new("StringValue", char)
stringVal.Name = "Hit"
stringVal.Value = char.Name
local hum = char:WaitForChild("Humanoid")
hum.Died:connect(function()
if game.Players:FindFirstChild(stringVal.Val) then
game.Players[stringVal.Value].leaderstats.Points.Value = game.Players[stringVal.Value].leaderstats.Points.Value = leaderstats.Points.Value + 1
end
end)
end)
end)


game.Debris:AddItem(force, .10)


end
end



function blow(hit)
local humanoid = hit.Parent:findFirstChild("Humanoid")
local vCharacter = Tool.Parent
local vPlayer = game.Players:playerFromCharacter(vCharacter)
local hum = vCharacter:findFirstChild("Humanoid") -- non-nil if tool held by a character
if humanoid~=nil and humanoid ~= hum and hum ~= nil then
-- final check, make sure sword is in-hand

local right_arm = vCharacter:FindFirstChild("Right Arm")
if (right_arm ~= nil) then
local joint = right_arm:FindFirstChild("RightGrip")
if (joint ~= nil and (joint.Part0 == sword or joint.Part1 == sword)) then
tagHumanoid(humanoid, vPlayer)
humanoid:TakeDamage(damage)
local d = vCharacter.Torso.CFrame.lookVector
windforce(Vector3.new(d.x, d.y, d.z), hit.Parent.Torso)
wait(1)
untagHumanoid(humanoid)
end
end


end
end

function tagHumanoid(humanoid, player)
local creator_tag = Instance.new("ObjectValue")
creator_tag.Value = player
creator_tag.Name = "creator"
creator_tag.Parent = humanoid
end

function untagHumanoid(humanoid)
if humanoid ~= nil then
local tag = humanoid:findFirstChild("creator")
if tag ~= nil then
tag.Parent = nil
end
end
end


function attack()
damage = slash_damage

local s = sounds[math.random(1,#sounds)]
s.Pitch = .9 + (math.random() * .2)
s.Volume = .7 + (math.random() * .3)
s:Play()

local anim = Instance.new("StringValue")
anim.Name = "toolanim"
anim.Value = "Slash"
anim.Parent = Tool
end



function swordUp()
Tool.GripForward = Vector3.new(-1,0,0)
Tool.GripRight = Vector3.new(0,1,0)
Tool.GripUp = Vector3.new(0,0,1)
end

function swordOut()
Tool.GripForward = Vector3.new(0,0,1)
Tool.GripRight = Vector3.new(0,-1,0)
Tool.GripUp = Vector3.new(-1,0,0)
end

function swordAcross()
-- parry
end


Tool.Enabled = true
local last_attack = 0
function onActivated()

if not Tool.Enabled then
return
end

Tool.Enabled = false

local character = Tool.Parent;
local humanoid = character.Humanoid
if humanoid == nil then
print("Humanoid not found")
return
end


attack()



wait(.5)

Tool.Enabled = true
end


function onEquipped()
UnsheathSound:play()
end


script.Parent.Activated:connect(onActivated)
script.Parent.Equipped:connect(onEquipped)


connection = sword.Touched:connect(blow)
Report Abuse
CrazyMe13 is not online. CrazyMe13
Joined: 07 Aug 2010
Total Posts: 45
24 Apr 2015 03:08 PM
The weapon is not working anymore if I use your script /\
Report Abuse
CrazyMe13 is not online. CrazyMe13
Joined: 07 Aug 2010
Total Posts: 45
24 Apr 2015 03:52 PM
The script analysis says: "Expected identifier,got '='"
Report Abuse
CrazyMe13 is not online. CrazyMe13
Joined: 07 Aug 2010
Total Posts: 45
24 Apr 2015 03:53 PM
At line 9, the last =
Report Abuse
buildersteven4 is not online. buildersteven4
Joined: 08 May 2009
Total Posts: 1325
24 Apr 2015 04:15 PM
use the union tool for solid modelling :3
Report Abuse
TheNewChicken is not online. TheNewChicken
Joined: 18 Mar 2015
Total Posts: 1997
24 Apr 2015 04:16 PM
if u want ill give mine, should be compatable.
also more efficient.

God grant me the wisdom to not punch stupid ppl, for I know I will go to prison.
Report Abuse
CrazyMe13 is not online. CrazyMe13
Joined: 07 Aug 2010
Total Posts: 45
25 Apr 2015 08:07 AM
b
Report Abuse
TheNewChicken is not online. TheNewChicken
Joined: 18 Mar 2015
Total Posts: 1997
25 Apr 2015 08:10 AM
local swinging = false
local hitting = false
script.Parent.Equipped:connect(function(mouse)
local p = game.Players:GetPlayerFromCharacter(script.Parent.Parent)
p.Backpack.PlayerFunctions.Disabled = true
mouse.Icon = "rbxasset://textures\\GunCursor.png"
mouse.Button1Down:connect(function()
if not swinging then
swinging = true
local anim = Instance.new("StringValue",script.Parent)
anim.Name = "toolanim"
anim.Value = "Slash"
wait(2.3)
swinging = false

end ; end) ; end)
script.Parent:WaitForChild("Handle").Touched:connect(function(hit)
if hit.Parent then
local human = hit.Parent:FindFirstChild("Survivor")
if human then
if hit.Parent ~= script.Parent.Parent then
if not hitting then
hitting = true
if swinging then
human:TakeDamage(10)
end
hitting = false
end ; end ; end ; end ; end)
Report Abuse
CrazyMe13 is not online. CrazyMe13
Joined: 07 Aug 2010
Total Posts: 45
25 Apr 2015 09:55 AM
b
Report Abuse
CrazyMe13 is not online. CrazyMe13
Joined: 07 Aug 2010
Total Posts: 45
25 Apr 2015 01:13 PM
b
Report Abuse
CrazyMe13 is not online. CrazyMe13
Joined: 07 Aug 2010
Total Posts: 45
25 Apr 2015 02:30 PM
b
Report Abuse
CrazyMe13 is not online. CrazyMe13
Joined: 07 Aug 2010
Total Posts: 45
25 Apr 2015 05:28 PM
b ;-;
Report Abuse
CrazyMe13 is not online. CrazyMe13
Joined: 07 Aug 2010
Total Posts: 45
26 Apr 2015 11:23 AM
b
Report Abuse
TheNewChicken is not online. TheNewChicken
Joined: 18 Mar 2015
Total Posts: 1997
26 Apr 2015 11:30 AM
i gave u a script ch00b

God grant me the wisdom to not punch stupid ppl, for I know I will go to prison.
Report Abuse
CrazyMe13 is not online. CrazyMe13
Joined: 07 Aug 2010
Total Posts: 45
27 Apr 2015 02:08 PM
Its not what I need and I told you that.
Report Abuse
buildersteven4 is not online. buildersteven4
Joined: 08 May 2009
Total Posts: 1325
27 Apr 2015 06:59 PM
haven't really read this all, but how about this, add this to the end of the first script:

function onPlayerAdded(plr)
plr.CharacterAdded:connect(function(char)
local stringVal = Instance.new("StringValue", char)
stringVal.Name = "Hit"
stringVal.Value = char.Name
local hum = char:WaitForChild("Humanoid")
hum.Died:connect(function()
if game.Players:FindFirstChild(stringVal.Val) then
game.Players[stringVal.Value].leaderstats.Points.Value = game.Players[stringVal.Value].leaderstats.Points.Value = leaderstats.Points.Value + 1
end
end)
end)
end)

for _, player in pairs(game.Players:GetPlayers()) do
onPlayerAdded(player)
end

game.Players.PlayerAdded:connect(onPlayerAdded)
Report Abuse
CrazyMe13 is not online. CrazyMe13
Joined: 07 Aug 2010
Total Posts: 45
30 Apr 2015 03:26 AM
/\ The weapon is not working anymore.
Report Abuse
buildersteven4 is not online. buildersteven4
Joined: 08 May 2009
Total Posts: 1325
30 Apr 2015 04:40 AM
then maybe it helps if you say what error it gives you...
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 2Go to page: [1], 2 Next
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image