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

Why is this trigger part not triggering?

I wanna make a soda fountain and when the player's cup touches the trigger part, it displays the soda in the cup and from the spout, but I wanna use a print statement just to make sure it works, and nothing comes up in the output. (This is inside a local script inside of the trigger part)

local tp  = script.Parent

local cup = game.Players.LocalPlayer.Backpack.Cup

tp.Touched:Connect(function(hit)
	if hit.Parent.Name == "Cup" then
		print("works")
	end
end)

1 answer

Hello.


LocalScript's only run if it's a descendant of the following:

  • ReplicatedFirst

  • StarterPlayerScripts

  • StarterCharacterScripts

  • A player's character

  • PlayerGui


You put the LocalScript inside a part that is inside Workspace. Instead, put it inside one of those.

1 comment

0

I already fixed it by setting it to a script. But thanks for answering!

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