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

OnTouched script not working or responding or printing any output?

Why isn't this working? When I put a print in it it also has no output.

local db = false

script.Parent.Touched:Connect(function(chr)
	if (db == false) and chr.Parent:FindFirstChild("Humanoid") then
		db = true
		chr.Parent.Humanoid.WalkSpeed = 0
		chr.Parent.Humanoid.JumpPower = 0
		game.ReplicatedStorage.Died:FireAllClients()
		wait(6)
		db = false
	end
end)

3 comments

0

I ran it in studio and commented out the game.ReplicatedStorage line. My character could not jump or walk so it worked. I am guessing the problem may be in the Died remote event. Can you pos code when that event is called?

0

Also I've made the mistake many times before of having the output window closed. To open it look at the top bar of studio -> view -> output. That is where you should see the print output

0

Is your script disabled perhaps?

2 answers

What i'd recommend to find the error is do this...

local db = false
print(1)
script.Parent.Touched:Connect(function(chr)
print(2)
    if (db == false) and chr.Parent:FindFirstChild("Humanoid") then
print(3)
        db = true
print(4)
        chr.Parent.Humanoid.WalkSpeed = 0
print(5)
        chr.Parent.Humanoid.JumpPower = 0
print(6)
        game.ReplicatedStorage.Died:FireAllClients()
print(7)
        wait(6)
print(8)
        db = false
print(9)
    end
end)

This should help you find the line that's causing error..

5 comments

0

Not working or giving any error :/

0

Where is the script located and what type of script is it?

0

@MillerrIAm It's in workspace.BullsEye.LavaPart and it's a normal server script.

0

Odd...

0

I have no idea then, i'm sorry

Dunno. Maybe this?

local db = false

script.Parent.Touched:Connect(function(chr)
    if db == false and chr.Parent:FindFirstChild("Humanoid") then
        db = true
        chr.Parent.Humanoid.WalkSpeed = 0
        chr.Parent.Humanoid.JumpPower = 0
        game.ReplicatedStorage.Died:FireAllClients()
        wait(6)
        db = false
    end
end)

1 comment

0

I just took the brackets away I don't know if it will do anything.

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