Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

LocalScript does not teleport Player to Seat?

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

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

5 comments

0

Hm, it still does not work, I even tried making a new transparent part, still doesnt work.

0

I edited it, check it out

0

I dont know what is wrong, but it still doesnt work. I dont get an error too.

0

I'm assuming it has something to do with the whole ' if not char or not char.Parent then' thing, 1 sec

0

try it now

This discussion is preserved as it was. New answers, comments, and votes are closed.