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

Why Is My Death Handler For An Obby Not Working?

So I made a script Called "DeathHandler" In ServerScriptService and this is the code.

game.Players.PlayerAdded:Connect(function(player)
	print("Player Added Yay!")
	local Stage = player:WaitForChild("leaderstats"):WaitForChild("Stage")
	player.CharacterAdded:Connect(function(character)
		print("Character Added!")
		local StagePart = game.Workspace:FindFirstChild(Stage.Value)
		print(StagePart)
		character.HumanoidRootPart.Position = StagePart.Position + Vector3.new(0, 5, 0)
		print("Done!")
	end)
end)

The script is supposed to spawn a character on a stage part. The problem is that it doesn't do that. I have tried debugging it by print and I have tried doing it by Humanoid.Died as well. Also, Stage is a string value.

1 comment

0

CFrame, not Position

1 answer

✓ Accepted answer

Hi! Try using CFrame instead. Fixed Code:

game.Players.PlayerAdded:Connect(function(player)
    print("Player Added Yay!")
    local Stage = player:WaitForChild("leaderstats"):WaitForChild("Stage")
    player.CharacterAdded:Connect(function(character)
        print("Character Added!")
        local StagePart = game.Workspace:FindFirstChild(Stage.Value) --Just incase use the tostring() function to make a it a string.
        print(StagePart)
        character.HumanoidRootPart.CFrame = CFrame * CFrame.new(0, 5, 0) --Its supposed to be times not add btw
        print("Done!")
    end)
end)

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