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?

3 comments
Please indent your code before doing anything else. getPlayerFromCharacter and connect and findFirstChild are deprecated, use GetPlayerFromCharacter and Connect and FindFirstChild. Also don't use global variables but local ones.
^ true
You have to put Money.Value < 1000 and everywhere u see Money put .Value to it