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

Workspace.TeamChangeDeath:7: attempt to concatenate global 'player' (a userdata value)?

Asked by 6 years ago
function HDied(aplayer)
wait(1)
player = game.Players:GetPlayerFromCharacter(aplayer)
if player ~= nil then
    game.Lighting.GuiFlash.Value = false
    print(player)
    game.Lighting.GuiText.Value = (player.. " has died!")
    player.TeamColor = BrickColor.new("Forest green")
end
end

please help!

1 answer

Log in to vote
1
Answered by 6 years ago

aplayer I'm assuming is an Instance of a player to fix this, just do player.Name instead of trying to concatenate just player (an instance)

function HDied(aplayer)
wait(1)
player = game.Players:GetPlayerFromCharacter(aplayer)
if player then -- ~= nil is not necessary unless you have to state it as a comparison
    game.Lighting.GuiFlash.Value = false
    print(player)
    game.Lighting.GuiText.Value = (player.Name.. " has died!")
    player.TeamColor = BrickColor.new("Forest green")
end
end

0
It does not work... MrWafflesNBacon -1 — 6y
0
Because you are using Lighting as a container, something you should NEVER be doing. lukeb50 631 — 6y
0
And it does help for us to know what is calling the HDied function as that could be a problem as well lukeb50 631 — 6y
0
I fixed it! MrWafflesNBacon -1 — 6y
0
it is important to put local before variables when putting variables in functions saSlol2436 716 — 6y
Ad

Answer this question