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

How to make part not activate .Touched event?

I have a race system and I'm making the checkpoints. I noticed that even when the checkpoint's Transparency property is 1 (not visible) the .Touched event runs. I browsed the part's properties and functions in the devforum but there is nothing that makes the .Touched event not run/run. ( this question has been deleted falsely for "not being constructive". that means i didnt attempt to find it, but as stated above: ". I browsed the part's properties and functions in the devforum but there is nothing that makes the .Touched event not run/run." i have clearly made an attempt. no hate on you leamir )

1 comment

1

just use if part.Transparency == 0 then <code> end

2 answers

You can't. Simple as that.

Well, hypothetically speaking, you can't without completely disabling the script. All script signals fire when their respective name happens (PlayerAdded firing when a player joins, for example). The best you could possibly do is tell the event to end when you'd want it to. There is no way to "disable" any specific script signals without disabling the actual script.

Signals fire no matter what. Even this fires:

script.Parent.Touched:Connect(function()
	if nil then
		-- above condition will never pass
	end
end)

So, "disabling" a signal is really locking it to being unable to get past a line of code. The signal itself can't actually be disabled.

That being said, RBXScriptConnection lines exist, and you can disconnect a signal but you still can't disable it:

local t = script.Parent.Touched:Connect(function()
	if nil then
		-- above condition will never pass
	end
end)
t:Disconnect()
-- despite the disconnection the signal can still fire in other functions

1 comment

0

Speaking variable-wise "nil" is really a placeholder for anything that will prevent the condition from passing every single time

Just make it so it goes to serverstorage until you want it to

wait(10)
workspace.CheckPointName.Parent = game:GetService("ServerStorage")
wait(10)
game:GetService("ServerStorage").CheckPointName.Parent = workspace

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