Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Script not working, when humanoid touches another humanoid, suppose to damage?

Asked by 10 years ago

So basically, LogiaNumber is like a activation, if it's 0 then you don't get the effect, but if it's 1 then you do get the effect, when other players try to touch you they get damage, but it's not working?

local player = game.Players.LocalPlayer
local Character = player.Character

if player.Leaderstats.LogiaNumber == 1 then
    if Character:FindFirstChild('Right Arm').Touched:connect(function(otherpart) 
    elseif Character:FindFirstChild('Left Arm').Touched:connect(function(otherpart) 

    end)
        then
        otherpart.Parent:FindFirstChild('Humanoid').Health = -3
    end
end

2 answers

Log in to vote
1
Answered by
Gamenew09 180
10 years ago
local player = game.Players.LocalPlayer

local Character = player.Character

function hurt(otherpart)
    otherpart.Parent:FindFirstChild('Humanoid').Health = otherpart.Parent:FindFirstChild('Humanoid').Health - 3
end

if player.leaderstats.LogiaNumber == 1 then
Character:FindFirstChild('Right Arm').Touched:connect(function(otherpart) 
    hurt(otherpart)
end)
Character:FindFirstChild('Left Arm').Touched:connect(function(otherpart)
    hurt(otherpart)
end)

end

The code that was provided by 1234 caused the unexpected symbol error because you can't use an if statement on an connection. Remove the if, then, elseif, and the second to last end. Then add the ends to the functions. You also need to pass the otherpart variable through the hurt function otherwise it will give an nil variable error. And to remove 3 health from the otherpart you need to subtract the health by 3.

If this helped please rate up and set this as the answer.

Ad
Log in to vote
0
Answered by 10 years ago

Does your leaderboard work? Because I think leaderstats is meant to have a lower case "L"? I also cleared it up a bit...

local player = game.Players.LocalPlayer

local Character = player.Character

function hurt()
    otherpart.Parent:FindFirstChild('Humanoid').Health = -3
end

if player.leaderstats.LogiaNumber == 1 then
 if Character:FindFirstChild('Right Arm').Touched:connect(function(otherpart) then
    hurt()
  elseif Character:FindFirstChild('Left Arm').Touched:connect(function(otherpart)
    hurt()
end)

end

end
0
Seems more corrected now, but there's another error now and it says "unexpected symbol near "then" HornedWyven 10 — 10y

Answer this question