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

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

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

✓ Accepted answer

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

5 comments

0

It does not work...

0

Because you are using Lighting as a container, something you should NEVER be doing.

0

And it does help for us to know what is calling the HDied function as that could be a problem as well

0

I fixed it!

0

it is important to put local before variables when putting variables in functions

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