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
4 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:

--Teleport to mats

local function TeleportToMat()
    local player = game.Players.LocalPlayer
    local char = player.Character
    if not char or not char.Parent then
    char = player.CharacterAdded:wait()
    end
    char.Position:SetPrimaryPartCFrame(workspace.Mat1.Position)
end

local RemoteEvent = game.ReplicatedStorage.RemoteFunction
RemoteEvent.OnClientEvent:Connect(TeleportToMat())

3 answers

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

Use Script instead of LocalScript.

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

Try this:


local whereTo = workspace:FindFirstChild('Mat1') if whereTo then char:SetPrimaryPartCFrame(whereTo.CFrame) end

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

Edited:

local function TeleportToMat()
    local player = game.Players.LocalPlayer
    local char = player.Character
    --if not char or not char.Parent then
    --  char = player.CharacterAdded:wait()
    --end
    repeat wait()
        char = player.Character
    until char ~= nil
    char:SetPrimaryPartCFrame(workspace.Mat1.CFrame) -- Changed that to what I set, Remember MUST BE A BASEPART NOT A MODEL
end

local RemoteEvent = game.ReplicatedStorage.RemoteFunction
RemoteEvent.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 — 4y
0
I edited it, check it out IDKBlox 349 — 4y
0
I dont know what is wrong, but it still doesnt work. I dont get an error too. DogeIXX 172 — 4y
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 — 4y
0
try it now IDKBlox 349 — 4y
Log in to vote
0
Answered by
Rynappel 212 Moderation Voter
4 years ago

Try a script

Answer this question