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

Why isnt this player died function working?

Asked by
TrollD3 105
9 years ago

I updated my script that I made but it still doesn't work. It is very very frustrating. All I want to do is make a txt label show the score of a team's kills. For example, If a player from one team killed another player from a different team, they would have 1 point added to the textlabel. Someone please help me make this work. I also am trying to make the points start at 0. For this it starts at 1 for some reason.

Script:

--Local Script
function FR()
    workspace.Player.Humanoid.Died:connect()
    if game.Players.LocalPlayer.TeamColor == BrickColor.new("Camo") then
        game.Teams.Sentinel.Score = game.Teams.Sentinel.Score +1
        script.Parent.Text = game.Teams.Sentinel.Score
    end --close the if statement with an end.
 end
FR()
0
xD advanced warfare for roblox BSIncorporated 640 — 9y

1 answer

Log in to vote
5
Answered by
xPolarium 1388 Moderation Voter
9 years ago

First off, you're putting in things in the local script that wouldn't work. Such as the connecting event on line 3. You could try doing this by starting with defined variables and the main code with a better connecting event.

You should first define the Player and then the Player's Character or Humanoid in a variable by simply doing:

--In a LocalScript

local player = game.Players.LocalPlayer
--then define the Humanoid
local character = player.Character

So now we can start the code with the Died event.

character:WaitForChild("Humanoid").Died:connect(function()
    if player.TeamColor == "Bright blue" then --You could change this color to your own.
        game.Teams.Sentinel.Score.Value = game.Teams.Sentinel.Score.Value + 1 
        script.Parent.Text = game.Teams.Sentinel.Score.Value
--Assuming "Score" is a IntValue, then add `.Value` to it. This would give an error without it.

    elseif player.TeamColor == "Bright red" then --You could change this color to your own.
--What i've done is, what if the other team kills the other person? This would give them a score as well.
        game.Teams.TEAM2.Score.Value = game.Teams.TEAM2.Score.Value + 1 
        script.Parent.Text = game.Teams.TEAM2.Score.Value
--Change TEAM2 to your other team, besides "Sentinel".



    end -- Closes the first if on line 2 
end) --Closes the Died Function on line 1

If you need any more help then please reply. This is just a hunch on what you needed. I suggest looking into the default Roblox Leaderboard scripts to get a better look on what you need.

0
Idk if I need an int value for the score because the score is inside the team properties. And The Value would be the number of the score right, so why do I need an int value for value? I think im confused. TrollD3 105 — 9y
0
Oh okay. Sorry lol. You can forget the IntValue then. It should be the same thing if you take away .Value xPolarium 1388 — 9y
0
Also its giving me ann error in output. It says attempting to index local character a nil value. TrollD3 105 — 9y
Ad

Answer this question