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

how to team change or spectate on death?

Ive been working on working on a team change on death for my game, and i have it working with a button click, but can't figure out how to make it work on death

here is what I have

local plr = script.Parent.Parent.Parent.Parent.Parent.Name

script.Parent.MouseButton1Click:connect(function() game.Players[plr].TeamColor = BrickColor.new("Bright blue") game.Workspace[plr].Humanoid.Health="0" script.Parent.Parent.Parent.Enabled=false end)

1 comment

0

Try reading this to post better questions: https://scriptinghelpers.org/help/how-post-good-questions-answers I don't have little to no info and I can't help, sorry!

1 answer

Simple.

local player = game.Players.LocalPlayer
if not player.Character then
	player.CharacterAdded:Wait()
end
local character = player.Character
local humanoid = player:FindFirstChild("Humanoid")
humanoid.Died:Connect(function()
	player.TeamColor = BrickColor.new("Bright blue")
	script:Destroy() --deletes the script so after you change teams it doesnt keep running
end)

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