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

How do i make a player touch a part which enables a script in ServerScriptService?

I'm having trouble fixing this problem, the script enables itself without the player touching the part. Here's the script (not localscript) script.Parent.Touched:Connect(function(touch) game.ServerScriptService.Handler.Disabled = false end) This is probably a really easy thing to fix but I'm an idiot soo...

1 answer

✓ Accepted answer

Hi! It runs the code with out a player touching it because the touched event fires when anything touches it not just player. Luckily you can easily check if its a player with a simple if statement.

Example:

script.Parent.Touched:Connect(function(touch) 
	if touch and touch.Parent.Humanoid then
		--Your code here
	end
end)

1 comment

0

This should be more better: if touch and touch.Parent:FindFirstChild('Humanoid') then

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