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

Why isn't this functioning?

Asked by 8 years ago
function OnTouch(hit)
    torso = hit.Parent:FindFirstChild("Torso")
    head = hit.Parent:FindFirstChild("Head")
    leftarm = hit.Parent:FindFirstChild("Left Arm")
    rightarm = hit.Parent:FindFirstChild("Right Arm")
    leftleg = hit.Parent:FindFirstChild("Left Leg")
    rightleg = hit.Parent:FindFirstChild("Right Leg")
    humanoid = hit.Parent:FindFirstChild("Humanoid")
    if (humanoid ~= nil) then
        torso.Anchored = true
        leftarm.Anchored = true
        rightarm.Anchored = true
        leftleg.Anchored = true
        rightleg.Anchored = true
        head.Anchored = true
        humanoid.Health = humanoid.Health - 5
        wait(0.1)
        humanoid.Health = humanoid.Health - 5
        wait(0.3)
        humanoid.Health = humanoid.Health - 5
        wait(0.5)
        humanoid.Health = humanoid.Health - 5
        wait(0.7)
        humanoid.Health = humanoid.Health - 5
        wait(3)
    if (humanoid ~= nil) then
        torso.Anchored = false
        leftarm.Anchored = false
        rightarm.Anchored = false
        leftleg.Anchored = false
        rightleg.Anchored = false
        head.Anchored = false
    end
end

script.Parent.Touched:connect(OnTouch)

That's what i have so far I'm trying to make a temporary freeze script. One that keeps that in place for just 5 seconds

1
Please use the lua formatting. To do this, edit your question by going to the right and click on edit, then a textbox should appear, click the Lua Symbol above the textbox, and insert your script into the lua box. Async_io 908 — 8y
0
fixed it Jakuten 5 — 8y

1 answer

Log in to vote
0
Answered by
Pyrondon 2089 Game Jam Winner Moderation Voter Community Moderator
8 years ago

You're missing an end after line 25.

function OnTouch(hit)
    torso = hit.Parent:FindFirstChild("Torso")
    head = hit.Parent:FindFirstChild("Head")
    leftarm = hit.Parent:FindFirstChild("Left Arm")
    rightarm = hit.Parent:FindFirstChild("Right Arm")
    leftleg = hit.Parent:FindFirstChild("Left Leg")
    rightleg = hit.Parent:FindFirstChild("Right Leg")
    humanoid = hit.Parent:FindFirstChild("Humanoid")
    if (humanoid ~= nil) then
        torso.Anchored = true
        leftarm.Anchored = true
        rightarm.Anchored = true
        leftleg.Anchored = true
        rightleg.Anchored = true
        head.Anchored = true
        humanoid.Health = humanoid.Health - 5
        wait(0.1)
        humanoid.Health = humanoid.Health - 5
        wait(0.3)
        humanoid.Health = humanoid.Health - 5
        wait(0.5)
        humanoid.Health = humanoid.Health - 5
        wait(0.7)
        humanoid.Health = humanoid.Health - 5
        wait(3)
    end
    if (humanoid ~= nil) then
        torso.Anchored = false
        leftarm.Anchored = false
        rightarm.Anchored = false
        leftleg.Anchored = false
        rightleg.Anchored = false
        head.Anchored = false
    end
end

script.Parent.Touched:connect(OnTouch)

Ad

Answer this question