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

.Touched script won't work anymore for some reason?

Hello, I made a script that would active smoke inside a part, but for some reason it won't work anymore. This is a ServerScript.

script.Parent.Touched:Connect(function(Part)
	if script.Parent.HasHit.Value == false then
		script.Parent.HasHit.Value = true
		script.Parent.Anchored = true
		script.Parent.Smoke.Enabled = true
		wait(30)
		script.Parent:Destroy()
	else
		wait()
	end
end)

5 comments

0

What do you mean by not work anymore? Do you mean it doesnt work in general?

0

Nothing happens in the script. I even tried making it print a string when activated, that doesn't work.

0

The script isn't disabled, so I don't understand what's going on.

0

Ensure that your HasHit BooleanValue is set to False. Also, your .Touched event will fire when anything touches it(including parts around the world), so you should make sure that whatevers touching the part is indeed a player..

0

Any errors in the output?

1 answer

I messed about with the script in Studio, when it says

script.Parent.HasHit

it, for some reason, doesn't check for a child but rather a property of the part so what I did to resolve this is changing all of the

script.Parent.HasHit

into

script.Parent:FindFirstChild("HasHit")

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