-This script works perfectly fine, but not the way I specifically want it to. If a player dies he changes teams :D. To the team I want! But I only want this to be able to happen during a certain time. If I copy and paste this script from server storage, it doesn't work, it has to stay in workspace. If I disable it and re-able it, it doesn't work either. I guess I am trying to say I need this script to be able to be pasted from ServerStorage into fine working conditions.
Here is the script:
function Deadesy(blabz) wait(1) local a = game.Players:GetPlayerFromCharacter(blabz) if a ~= nil then a.TeamColor = BrickColor.new("Bright green") end end function Livesy(KILLA) KILLA.Humanoid.Died:connect( function() Deadesy(KILLA) end ) end function BANOs(Playa) Playa.CharacterAdded:connect(Livesy) end game.Players.PlayerAdded:connect(BANOs)
This problem is simple, you need to use ServerScriptService
, rather than using ServerStorage
. Also, i've gone through your script and tabbed it. I also named your functions, because when going through your functions it will be allot easier to edit. If you don't understand why, I suggest reading the blog post on this website titled Clean and Tidy.
function changeTeams(player) wait(1) local deadPlayer = game.Players:GetPlayerFromCharacter(player) if deadPlayer ~= nil then deadPlayer.TeamColor = BrickColor.new("Bright green") end end function deathCheck(player) player.Humanoid.Died:connect(function() changeTeams(player) end) end function playerAdded(player) player.CharacterAdded:connect(player) end game.Players.PlayerAdded:connect(playerAdded)
Here are some links to roblox wiki pages to explain the difference between ServerStorage
and ServerScriptService
: