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

Trying to change spawn positions without spawnlocation?

Asked by 6 years ago

So I am making a game with levels and each level has a spawn. I don't want to have to use teams and stuff so I wanted to make a custom spawn system but when the player spawns it they just spawn in the middle of the map and their position doesn't change. I checked with a print to see if coordinates were actually given, and there was so I have no idea why this isn't working.

I tried asking in the scripting forum on Roblox and no one helped me so I am hoping one of you guys will

game.Players.PlayerAdded:connect(function(player)
    player.Team = game.Teams.Grassland
    local Level = Instance.new("StringValue", player)
    Level.Value = "G1"
    player.CharacterAdded:connect(function()
        player.Character.HumanoidRootPart.CFrame = CFrame.new(Vector3.new(workspace.Spawns:FindFirstChild(Level.Value).Position.X, workspace.Spawns:FindFirstChild(Level.Value).Position.Y + 2.55, workspace.Spawns:FindFirstChild(Level.Value).Position.Z))
    end)
end)

1 answer

Log in to vote
0
Answered by 6 years ago

Try this,

game.Players.PlayerAdded:Connect(function(player)
    player.Team = game.Teams.Grassland
    local Level = Instance.new("StringValue", player)
    Level.Value = "G1"
    player.CharacterAdded:Connect(function(character)
    wait()
        character.HumanoidRootPart.CFrame = workspace.Spawns:FindFirstChild(Level.Value).CFrame
    end)
end)

You can't insert a Vector3 position inside a CFrame

Ad

Answer this question