0

# Script is supposed to check if points = 4 then add one win. Why is it not working?

Edited by T3_MasterGamer 22 days ago

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 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


1
Edited by T3_MasterGamer 22 days ago

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 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
end


Change (In Seconds) How Long It Takes To Trigger Option

local player = game.Players.LocalPlayer
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