I’m trying to make it so that every time player dies or resets, he spawns on one of the random checkpoints and the player’s camera is at specific position looking at the character. But my current scripts don’t seem to work, am I doing something wrong?
Local script in starter character scripts:
local player = game.Players.LocalPlayer
local camera = game.Workspace.CurrentCamera
local event = game.ReplicatedStorage.Events.Spawn
player.CharacterAdded:Connect(function(char)
print("spawned")
event.FireServer(char, camera)
end)
Regular script in server script service:
local Players = game:GetService("Players")
local event = game.ReplicatedStorage.Events.Spawn
local Spawns = game.Workspace.SpawnPoints:GetChildren()
event.OnServerEvent:Connect(function(player, char, camera)
print("spawned")
local spawn = Spawns[math.random(1, #Spawns)]
char.HumanoidRootPart.CFrame = spawn.CFrame + Vector3.new(0, 3, 0)
camera.CFrame = spawn.CFrame + Vector3.new(-6, 6, 0)
end)
The output shows nothing, there seem to be no errors, and I am assuming that the CharacterAdded event isn’t firing at all