I know how to do this with Touched scripts, but with a ClickDetector I'm lost. I have this gate and a button, but I only want the button to be activated if the player's name is the same as the Owner.Value within the tycoon. Here's the part I'm having trouble with
script.Parent.ClickDetector.MouseClick:connect(function(clicker) local player = game.Players:GetPlayerFromCharacter(clicker.Parent) if open == false and moving == false and script.Parent.Parent.Parent.Parent.Owner.Value==player then --gate script stuff
the script is within the button and the open and moving part can be ignored. The script works but when I try and make it run only when the players name matches with the owner value it stops working. Thanks for the help.
I see you've based your script of a part.Touched
event, which returns a part. A ClickDetector.MouseClick
events always returns a player, never a part (Why would it? There is no part). I would modify your code to look like this:
script.Parent.ClickDetector.MouseClick:connect(function(player) --Function goes here end)