amount = script.Parent.MoneyValue.Value wait_time = 10 -- change this to how long you want to wait x = script.Parent enabled = true function touch(hit) if not enabled then return end enabled = false local h = hit.Parent:findFirstChild("Humanoid") if h ~= nil then local p = game.Players:getPlayerFromCharacter(hit.Parent) local money = p.leaderstats.Money if p.TeamColor ~= BrickColor.new("Bright green") then if money < 1000 then end elseif money >= 1000 then money.Value = money.Value + amount script.Parent.MoneyValue.Value = 0 p.TeamColor = BrickColor.new("Bright green") x.Parent.Name = "Finished!" wait(wait_time) x.Parent.Name = "Complete Training: 1000" enabled = true end end end x.Touched:connect(touch)
I'm trying to make my script check for value before allowing players to switch teams. (Lines 15-18) Im making a brick change teams ontouch if the player just touches any brick then theyll have negative values for their money leaderstats and i'm trying to avoid players having debt on them. What is my script missing in order to preform a value check and if players pass the value check how can I continue the rest of the script?
I'm not going to solve this because I have better things to do but to anyone that is going to try to, here is the indented code:
amount = script.Parent.MoneyValue.Value wait_time = 10 -- change this to how long you want to wait x = script.Parent enabled = true function touch(hit) if not enabled then return end enabled = false local h = hit.Parent:findFirstChild("Humanoid") if h ~= nil then local p = game.Players:getPlayerFromCharacter(hit.Parent) local money = p.leaderstats.Money if p.TeamColor ~= BrickColor.new("Bright green") then if money < 1000 then end elseif money >= 1000 then money.Value = money.Value + amount script.Parent.MoneyValue.Value = 0 p.TeamColor = BrickColor.new("Bright green") x.Parent.Name = "Finished!" wait(wait_time) x.Parent.Name = "Complete Training: 1000" enabled = true end end end x.Touched:connect(touch)