I'm making a game that needs this. I made the script but somehow it doesn't work when I click it again.
Inside the part (w/ Click Detector) Script:
script.Parent.ClickDetector.MouseClick:Connect(function(player)
player:WaitForChild("PlayerGui").ScreenGui.Frame.Visible = true
end)
In Starter Gui: StarterGui, ScreenGui, Frame, TextButton, LocalScript
Inside the Local Script:
local player = game.Players.LocalPlayer
local target = game.Workspace.TeleportPart
script.Parent.MouseButton1Click:connect(function()
player.Character.HumanoidRootPart.CFrame = target.CFrame * CFrame.new(0,3,0)
player:WaitForChild("PlayerGui").ScreenGui.Frame.Visible = false
end)
When you click the "Part" again it doesn't work...Pls Help.

3 comments
I didn't know about Events and thank you for helping me!
no problem. here's roblox's guide about events. https://developer.roblox.com/en-us/api-reference/class/RemoteEvent. Btw you need RemoteEvent in this case because you cannot get the LocalPlayer via ServerScript directly unless you use functions like "PlayerAdded", "Part.Touched" etc. Therefore, because your case is "Clicked" function, you need a LocalScript
Also there is a problem with using "PlayerAdded" function to get the player. The "MouseClick" function can only be used once so once you clicked the part one time, it can't be clicked anymore. Thats why i suggest using RemoteEvent