Spawn Point With A Script

So I’m trying to make a spawn point with a script without using parts or spawn models.

This is where I’m at:

–Locals–
local player = game:GetService(‘Players’)
–Spawn–
player.CharacterAdded:Connect(function(character)
character:GetPropertyChangedSignal(“496.5, 26, -378.2”):Wait()
– set position
end)

But it does not work, anyone help?

1 Like

Please, if you want to share some code use `````` :slight_smile:

what is this? there is no attributes named like this

I said I am trying, can you help? That is the position of where the spawn is

local Players = game:GetService('Players')

local Spawn = nil

Players.PlayerAdded:Connect(function(NP)
  NP.CharacterAdded:Connect(function(c)
    c:MoveTo(Spawn.Position)
  end)
end

The first argument of the GetPropertyChangedSignal() function must be the name of the Property, not the value.

Ok! Thanks ill try it out and let you know.

Where would I put in the postion

You could just set the HumanoidRootPart’s Position to where that Vector3 value is

--Locals
local SpawnPosition = Vector3.new(496.5, 26, -378.2)
local Players = game:GetService("Players")

--Spawn
Players.PlayerAdded:Connect(function(Player)
    Player.CharacterAdded:Connect(function(Character)
        Character.HumanoidRootPart.Position = SpawnPosition
    end)
end)

Also this depends on what type of script this is, for this example this is a Server Script

what do you mean???


Where do i put in the postion nhumbers

Looks good! I tried it but for some reason it doesnt spawn me there

Hm, really? What type of script are you using this on?

Maybe I forgot to implement a WaitForChild() if that’s the case :thinking:

Just a normal script not local so it should work

Try this then:

--Locals
local SpawnPosition = Vector3.new(496.5, 26, -378.2)
local Players = game:GetService("Players")

--Spawn
Players.PlayerAdded:Connect(function(Player)
    Player.CharacterAdded:Connect(function(Character)
        Character:WaitForChild("HumanoidRootPart").Position = SpawnPosition
    end)
end)

This should work I believe? It should belong in ServerScriptService

Yeah I did put the script in the right area let me try this

Still no, but thanks for the srcipt! Ill work off of this and try some things with it to get it working! Thanks.

I think your issue may be that you have to use CFrame instead of Position to move the HumanoidRootPart?

--Locals
local SpawnPosition = CFrame.new(496.5, 26, -378.2)
local Players = game:GetService("Players")

--Spawn
Players.PlayerAdded:Connect(function(Player)
    Player.CharacterAdded:Connect(function(Character)
        Character:WaitForChild("HumanoidRootPart").CFrame = SpawnPosition
    end)
end)
1 Like

The issue is that the CharacterAdded event is fired too early, and your character is moved after this event happens.

Putting a wait() before changing the character’s position will fix that.

That would actually be a fair reason, although I think it may be the thing that the RootPart must be moved using CFrame instead of Position, but your reasons may be plausible.

Taking into account what you have said, the code should be this

--Locals
local SpawnPosition = CFrame.new(496.5, 26, -378.2)
local Players = game:GetService("Players")

--Spawn
Players.PlayerAdded:Connect(function(Player)
	local function moveCharacter(character)
		game:GetService("RunService").Heartbeat:Wait()
		character:WaitForChild("HumanoidRootPart").CFrame = SpawnPosition
	end
	
	moveCharacter(Player.Character or Player.CharacterAdded:Wait())
    Player.CharacterAdded:Connect(moveCharacter)
end)

This accounts for the things you have mentioned, it’ll wait a Heartbeat frame before changing the location, and just as a safety measure incase the character is added before the event was set up, a function should prevent that as well. Or I think a better way would be this

--Locals
local SpawnPosition = CFrame.new(496.5, 26, -378.2)
local Players = game:GetService("Players")

--Functions
local function moveCharacter(character)
	game:GetService("RunService").Heartbeat:Wait()
	character:WaitForChild("HumanoidRootPart").CFrame = SpawnPosition
end

--Spawn
Players.PlayerAdded:Connect(function(Player)
	moveCharacter(Player.Character or Player.CharacterAdded:Wait())
    Player.CharacterAdded:Connect(moveCharacter)
end)

So it doesn’t have to make the function again each time a player joins, but I think the former should still work fine as well

2 Likes