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

why isnt this player script working? NOT ANSWERED

Asked by
TrollD3 105
10 years ago

I assume that every time a player kills another player, their team gets points (correct me if im wrong). So I have a text label as the parent of this script. Every time a team scores, it should post that score inside the text label. It is not working and I want to know why.

Script:

1wait()
2 
3function FR()
4if game.Players.LocalPlayer.TeamColor == ("Bright red") then
5    script.Parent.Text = game.Teams.Atlas.Score
6end
7 
8FR()
9game.Teams.Atlas.Changed:connect(FR)
0
I told you, my script is not complete. Mainly since you're not allowed to post full scripts. I had in there under the "FR" section how to see if someone killed someone. EzraNehemiah_TF2 3552 — 10y

2 answers

Log in to vote
-1
Answered by 10 years ago

You forgot to add BrickColor.new before your brickcolor

1wait()
2 
3function FR()
4if game.Players.LocalPlayer.TeamColor == BrickColor.new ("Bright red") then
5    script.Parent.Text = game.Teams.Atlas.Score
6end
7 
8FR()
9game.Teams.Atlas.Changed:connect(FR)
Ad
Log in to vote
1
Answered by 10 years ago
  1. Why is there wait? You don't need one in this case.
  2. Why are you calling a function and then letting an event call the function?
  3. TeamColor is a BrickColor
  4. The Score script... Look up leaderboard in the wiki...

Wait

The wait is for when you are doing a PlayerAdded type event in a local script. You can't do player added in a local script. You can reach the player through LocalPlayer, but the script runs before the player joins. So that's why the wait is there.


FR

Why are you calling the function and then calling it again with an event? Why are you using a Changed event? You can see if a player died using the Died event.

1workspace.Player.Humanoid.Died:connect()
2    print("A person died!")
3end)

we can see who killed a player by using tags.

1workspace.Player.Humanoid.Died:connect()
2    if workspace.Player.Humanoid:FindFirstChild("Tag") then
3        print("Player was Killed by "..workspace.Player.Humanoid.Tag.Value.Name.."!")
4    else
5        print("A person died!")
6    end
7end)

To insert a tag, make an object value. The value of the object value will be the player who is trying to kill the other player.

01--This script will be in a sword or something.
02function tag(humanoid)
03    if not humanoid:FindFirstChild("tag") then
04        local tag = Instance.new("ObjectValue", humanoid)
05        tag.Name = "tag"
06        tag.Value = game:GetService("Players"):GetPlayerFromCharacter(script.Parent.Parent.Parent)
07        wait(2)
08        tag:Destroy()
09    end
10end
11 
12script.Parent.Touched:connect(function(char)
13    if char:FindFirstChild("Humanoid") then
14        tag(char.Humanoid)
15    end
16end)

TeamColor is a BrickColor

A TeamColor is a BrickColor! So instead of TeamColor == ("Bright red") try

1if game:GetService("Players").LocalPlayer.TeamColor == BrickColor.new("Bright red") then
2end

Leaderboard

Look here.



Here is a better version of your script. This isn't the whole thing, I'm just making the script work.

1--Local Script
2function FR()
3    if game.Players.LocalPlayer.TeamColor == BrickColor.new("Bright red") then
4        game.Teams.Atlas.Score = game.Teams.Atlas.Score+1
5        script.Parent.Text = game.Teams.Atlas.Score
6    end --close the if statement with an end.
7end
8 
9game.Players.LocalPlayer.Character.Humanoid.Died:connect(FR)



Hope this helps!

0
It does help but it just shows 1 on the gui. It doesnt go up when you kill a player TrollD3 105 — 10y

Answer this question