Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why isn't this functioning?

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

2 comments

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.

0

fixed it

1 answer

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)

This discussion is preserved as it was. New answers, comments, and votes are closed.