Script checks if player is on Red Team, if they are it checks if their points are 4 points if thats true it adds 1 win to them and makes a Frame visible.
local player = game.Players.LocalPlayer local points = player:WaitForChild("leaderstats"):WaitForChild("Points") local wins = player:WaitForChild("leaderstats"):WaitForChild("Wins") local Team = game:GetService("Teams") if player.Team.TeamColor == "Red Team" then if points.Value == 4 then wins.Value = wins.Value + 1 player:WaitForChild("PlayerGui"):WaitForChild("RedTeamWins").Frame.Visible = true end end
the reason why it isnt working is because the if value only checks the conditions once, so unless you have a loop or something like that, it will not check, you can use .Changed
so that the script runs whenever the value changes, or you can do either while true do
with task.wait()
, or while task.wait() do
to make it loop forever (you can put in a number in task.wait() if you want it to check every so often. i cant really explain stuff so sorry about that
Always Trigger Option
local player = game.Players.LocalPlayer local points = player:WaitForChild("leaderstats"):WaitForChild("Points") local wins = player:WaitForChild("leaderstats"):WaitForChild("Wins") local Team = game:GetService("Teams") while true do if player.Team.Name == "Red Team" then If points.Value == 4 then wins.Value = wins.Value + 1 player:WaitForChild("PlayerGui"):WaitForChild("RedTeamWins").Frame.Visible = true end end task.wait() end
Change (In Seconds) How Long It Takes To Trigger Option
local player = game.Players.LocalPlayer local points = player:WaitForChild("leaderstats"):WaitForChild("Points") local wins = player:WaitForChild("leaderstats"):WaitForChild("Wins") local Team = game:GetService("Teams") while task.wait() do -- leave it blank if you want it to trigger any time it can, enter a number if you want it to wait (in seconds) then trigger if player.Team.Name == "Red Team" then If points.Value == 4 then wins.Value = wins.Value + 1 player:WaitForChild("PlayerGui"):WaitForChild("RedTeamWins").Frame.Visible = true end end end
Triggers When Value Is Changed Option
local player = game.Players.LocalPlayer local points = player:WaitForChild("leaderstats"):WaitForChild("Points") local wins = player:WaitForChild("leaderstats"):WaitForChild("Wins") local Team = game:GetService("Teams") points.Changed:Connect(function() if player.Team.Name == "Red Team" then If points.Value == 4 then wins.Value = wins.Value + 1 player:WaitForChild("PlayerGui"):WaitForChild("RedTeamWins").Frame.Visible = true end end end)