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

This is a teleport to spawns location script. Why wont it work?

Spawns = game.Workspace.Easy1.Spawns

function Tele()
	wait(1)	
	game.Players.LocalPlayer.Character.Torso.CFrame = CFrame.new.[Spawns.Location] 
end

game.Players.PlayerAdded:connect(Tele)

Its supposed to teleport you to the location of a model named Spawns and it has parts in it but it doesn't teleport you to it

2 answers

There is one way to help, but Can you play your game from the actual page, pres f9 and screen shot the Log? e.g Server log. It will output any errors the script finds or if confused.

1 comment

0

nah mate there is more than one way to help. Error handling does not always give you the right direction to take in coding.

Lets guide you through your code to show what exactly is wrong. Starting with line 1.

Spawns = game.Workspace.Easy1.Spawns
-- This is good, we know where the first spawn is.

function Tele()-- this function is bad
    wait(1) 
    game.Players.LocalPlayer.Character.Torso.CFrame = CFrame.new[Spawns.Location] -- this is useless
end

game.Players.PlayerAdded:connect(Tele)-- playerAdded event requires a paramater to access the player

Here is the updated code.

Spawns = game.Workspace.Easy1.Spawns-- is this a model, I am treating spawns as a part, so if this is a model then you want it to get the location of every spawn position
function Tele(player)-- this function is bad
--    we want to wait for child
 player:WaitForChild("Character")
-- rather than use CFrame use the MoveTo property of a model
player.Character.MoveTo(Spawns.Position)
end
game.Players.PlayerAdded:connect(Tele)

also, if you really want to use CFrame you will need to multiply it. here is an example below (try this out in studio to see what it looks like.)

game.Workspace.(NameOfPlayer).Torso.CFrame =  game.workspace.Part.CFrame * CFrame.new(0,1,0);

And as a reminder The difference between using vector3 vs CFrame at least in roblox from what I have noticed is when dealing with CFrames you multiply, but when dealing with Vector3's your add

2 comments

0

How would i get the position of all parts in the model? :(

0

there is a position property of every part.

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