✓ Accepted answer
Well, you're using a script for what seems to be a job cut out for a LocalScript. .MouseButton1Down is meant as something registered on the Client. However, if you use a LocalScript, the teleport will only be registered on the client. We need to use a RemoteEvent to register it on the server. You can read more about RemoteEvents and Server stuff here. First, you need to create a RemoteEvent in the ReplicatedStorage of your game. Name it something.
This is what your local script should look like.
script.Parent.MouseButton1Click:connect(function()
game.ReplicatedStorage.TeleportEvent:FireServer()
end)
This is what your server script should look like, put it in the ServerScriptStorage.
game.ReplicatedStorage.TeleportEvent.OnServerEvent:connect(function(plr)
local BuggyLoc = CFrame.new(-106.428, 121.84, -194.854)
plr.Character.SetPrimaryPartCFrame(BuggyLoc)
end)
Hope that helped out, consider accepting this answer. If not, comment below and I'll be sure to help out further.
5 comments
Is it teleporting you to the right place, even though all players are teleporting.
Yes it is teleporting me to the car's seat, but all players are being teleported there and I don't want that.
So basically I think instead of using for i,v in pairs, you can use the parameter in the Tele I'll give an example in my answer.
local BuggyLoc = CFrame.new(-106.428, 121.84, -194.854) clickDetector = script.Parent local function onMouseClick(player) v = player v.Character:SetPrimaryPartCFrame(BuggyLoc) end clickDetector.MouseClick:connect(onMouseClick)
Oh by the way is this is in a local script?