Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

how to team change or spectate on death?

Asked by 4 years ago

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)

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! AidanTES 36 — 4y

1 answer

Log in to vote
0
Answered by 3 years ago

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)
Ad

Answer this question