Hey. I have following Problem. I did a LocalScript, which teleports the player to a mat. Now, it does not teleport the player to the seat.
Thats the script:
01 | --Teleport to mats |
02 |
03 | local function TeleportToMat() |
04 | local player = game.Players.LocalPlayer |
05 | local char = player.Character |
06 | if not char or not char.Parent then |
07 | char = player.CharacterAdded:wait() |
08 | end |
09 | char.Position:SetPrimaryPartCFrame(workspace.Mat 1. Position) |
10 | end |
11 |
12 | local RemoteEvent = game.ReplicatedStorage.RemoteFunction |
13 | RemoteEvent.OnClientEvent:Connect(TeleportToMat()) |
Try this:
1 | local whereTo = workspace:FindFirstChild( 'Mat1' ) |
2 |
3 | if whereTo then |
4 |
5 | char:SetPrimaryPartCFrame(whereTo.CFrame) |
6 | end |
This will ONLY WORK if 'Mat1' is a part and NOT a model
Edited:
01 | local function TeleportToMat() |
02 | local player = game.Players.LocalPlayer |
03 | local char = player.Character |
04 | --if not char or not char.Parent then |
05 | -- char = player.CharacterAdded:wait() |
06 | --end |
07 | repeat wait() |
08 | char = player.Character |
09 | until char ~ = nil |
10 | char:SetPrimaryPartCFrame(workspace.Mat 1. CFrame) -- Changed that to what I set, Remember MUST BE A BASEPART NOT A MODEL |
11 | end |
12 |
13 | local RemoteEvent = game.ReplicatedStorage.RemoteFunction |
14 | RemoteEvent.OnClientEvent:Connect(TeleportToMat) -- Set this to TeleportToMat |