so uhh, im trying to do a spawn location system, you can set your spawn location and stuff, but, the player only tp's to the location when he resets for the first time, and when he resets, he tp's but only in client, he stays at the same place im server

local Players = game:GetService("Players")
local RunService = game:GetService("RunService")

Players.PlayerAdded:Connect(function(plr)
	wait()
	plr.CharacterAdded:Connect(function(char)
		print("working")
		local spawnpoint = plr:WaitForChild("SpawnPoint")
		local root = char:WaitForChild("HumanoidRootPart")
		if spawnpoint.Value == "None" then
			local newspawnpoint = math.random(1,2)
			if newspawnpoint == 1 then
				spawnpoint.Value = "Forest"
				RunService.Stepped:wait()
				root.Position = Vector3.new(-1891.331, 6.676, -2221.528)
			end
			if newspawnpoint == 2 then
				spawnpoint.Value = "Desert"
				RunService.Stepped:wait()
				root.Position = Vector3.new(332.69, 22.027, -1245.51)
			end
		else
			if spawnpoint.Value == "Forest" then
				RunService.Stepped:wait()
				root.Position = Vector3.new(-1891.331, 6.676, -2221.528)
			elseif spawnpoint.Value == "Desert" then
				RunService.Stepped:wait()
				root.Position = Vector3.new(332.69, 22.027, -1245.51)
			end
		end
	end)
end)

if what i said is confuse, just comment

3 comments

0

forgot to say, that script is a server script in server script service

0

I think its that your using a local script, because local scripts is only on the client. 2 ways do to this. Make a remote event and Fire it to the server. Or if you want to be very detailed, Use remote functions.

0

as i said, its a server script in server script service