Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

LocalScript does not teleport Player to Seat?

Asked by
DogeIXX 172
5 years ago

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 
03local 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.Mat1.Position)
10end
11 
12local RemoteEvent = game.ReplicatedStorage.RemoteFunction
13RemoteEvent.OnClientEvent:Connect(TeleportToMat())

3 answers

Log in to vote
1
Answered by
ErtyPL 129
5 years ago

Use Script instead of LocalScript.

Ad
Log in to vote
0
Answered by
IDKBlox 349 Moderation Voter
5 years ago
Edited 5 years ago

Try this:

1local whereTo = workspace:FindFirstChild('Mat1')
2 
3if whereTo then
4 
5    char:SetPrimaryPartCFrame(whereTo.CFrame)
6end

This will ONLY WORK if 'Mat1' is a part and NOT a model

Edited:

01local 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.Mat1.CFrame) -- Changed that to what I set, Remember MUST BE A BASEPART NOT A MODEL
11end
12 
13local RemoteEvent = game.ReplicatedStorage.RemoteFunction
14RemoteEvent.OnClientEvent:Connect(TeleportToMat) -- Set this to TeleportToMat
0
Hm, it still does not work, I even tried making a new transparent part, still doesnt work. DogeIXX 172 — 5y
0
I edited it, check it out IDKBlox 349 — 5y
0
I dont know what is wrong, but it still doesnt work. I dont get an error too. DogeIXX 172 — 5y
0
I'm assuming it has something to do with the whole ' if not char or not char.Parent then' thing, 1 sec IDKBlox 349 — 5y
0
try it now IDKBlox 349 — 5y
Log in to vote
0
Answered by
Rynappel 212 Moderation Voter
5 years ago

Try a script

Answer this question