script.parent.GL.Touched:Connect(function(h) local hum = h.Parent:FindFirstChild("Humanoid") if hum ~= nil then h.parent.HumanoidRootPart.CFrame = CFrame.new(workspace["TelElTo"].Position) end end) script.parent.GR.Touched:Connect(function(h) local hum = h.Parent:FindFirstChild("Humanoid") if hum ~= nil then h.parent.HumanoidRootPart.CFrame = CFrame.new(workspace["TelElTo"].Position) end end)
What i have to change in the script, when a player CLICKED and not touched the part that he will be teleported?
You would have to add a "ClickDetector" inside your part. Then you need to add a local script into PlayerStarter --> StarterPlayerScripts.
Here is an example:
My part inside the Workspace
Workspace -- > gameT (part) --> ClickDetector
My local script:
function clicked() print("Hello!") end game.Workspace.gameT.ClickDetector.MouseClick:Connect(clicked)
You'd have to use a ClickDetector instance. ClickDetector are used to allow Models/Parts to be clicked and fire an event upon being clicked (if the script is connected to it).
ServerScript
function OnMouseClick(Player) -- Keep in mind, player is always fired over as an argument print('The Player who clicked this is: '..Player.Name) end local Part = script.Parent local ClickDetector = Instance.new('ClickDetector') ClickDetector.Parent = Part ClickDetector.MouseClick:Connect(OnMouseClick)
Put this code in a ServerScript and put the script inside a part you want to be clicked.