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:
wait() function FR() if game.Players.LocalPlayer.TeamColor == ("Bright red") then script.Parent.Text = game.Teams.Atlas.Score end FR() game.Teams.Atlas.Changed:connect(FR)
You forgot to add BrickColor.new before your brickcolor
wait() function FR() if game.Players.LocalPlayer.TeamColor == BrickColor.new ("Bright red") then script.Parent.Text = game.Teams.Atlas.Score end FR() game.Teams.Atlas.Changed:connect(FR)
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.
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.
workspace.Player.Humanoid.Died:connect() print("A person died!") end)
we can see who killed a player by using tags.
workspace.Player.Humanoid.Died:connect() if workspace.Player.Humanoid:FindFirstChild("Tag") then print("Player was Killed by "..workspace.Player.Humanoid.Tag.Value.Name.."!") else print("A person died!") end end)
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.
--This script will be in a sword or something. function tag(humanoid) if not humanoid:FindFirstChild("tag") then local tag = Instance.new("ObjectValue", humanoid) tag.Name = "tag" tag.Value = game:GetService("Players"):GetPlayerFromCharacter(script.Parent.Parent.Parent) wait(2) tag:Destroy() end end script.Parent.Touched:connect(function(char) if char:FindFirstChild("Humanoid") then tag(char.Humanoid) end end)
A TeamColor is a BrickColor! So instead of TeamColor == ("Bright red")
try
if game:GetService("Players").LocalPlayer.TeamColor == BrickColor.new("Bright red") then end
Look here.
Here is a better version of your script. This isn't the whole thing, I'm just making the script work.
--Local Script function FR() if game.Players.LocalPlayer.TeamColor == BrickColor.new("Bright red") then game.Teams.Atlas.Score = game.Teams.Atlas.Score+1 script.Parent.Text = game.Teams.Atlas.Score end --close the if statement with an end. end game.Players.LocalPlayer.Character.Humanoid.Died:connect(FR)
Hope this helps!