Okay, so i have been trying to fix this for hours now, when i click on the brick it's supposed to give me cookies but instead of giving me any cookies it gives me 0 cookies, any ideas?
local Terrain = Workspace.Terrain local Players = game:GetService 'Players' local Lighting = game:GetService 'Lighting' local StarterGui = game:GetService 'StarterGui' local StarterPack = game:GetService 'StarterPack' local Debris = game:GetService 'Debris' local button = script.Parent local detector = button.ClickDetector local BillboardGui = script:WaitForChild("BillboardGui") local Owner = script.Parent.Parent:WaitForChild("SheetOwner") local function Add(Cookies, Value) local NewValue = Instance.new("IntValue") NewValue.Name = "Add"; NewValue.Value = Value; NewValue.Parent = Cookies; end local function DisplayIncrease(Increase) Spawn(function() local lag = wait() if lag < 0.05 then local New = BillboardGui:Clone() New.Parent = script.Parent New.Name = "Additionkk"; New.Count.Text = Increase New.Adornee = script.Parent New.Enabled = true local X, Y = math.random(-5, 5), math.random(-5, 5) New.StudsOffset = Vector3.new(X, 0, Y); for i=0, 20 do wait(0.1) New.StudsOffset = Vector3.new(X, i/2, Y); New.Count.TextTransparency = i/20 end wait() New:Destroy() end end) end local function CheckCharacter(Character) -- Checks to see if the character has a valid humanoid and torso. Useful function. return Character and Character:FindFirstChild("Humanoid") and Character:FindFirstChild("Torso") and Character.Humanoid:IsA("Humanoid") and Character.Torso:IsA("BasePart") end local Stolen = 5 local OwnersCookies = math.huge; local CanSteal = true; local LastTime = tick() Spawn(function() while true do wait(60) LastTime = tick() CanSteal = true; if Owner.Value then local leaderstatsOwner = Owner.Value:FindFirstChild("leaderstats") if leaderstatsOwner then local OwnerCookieValue = leaderstatsOwner:FindFirstChild("Cookies") if OwnersCookies * 0.30 < Stolen then CanSteal = false; end OwnersCookies = OwnerCookieValue.Value end else OwnersCookies = math.huge; end Stolen = 5; end end) local function MouseClick(player) Spawn(function() local CookiesGainedPerClick = player:FindFirstChild("CookiesGainedPerClick") and player.CookiesGainedPerClick.Value or 1; if player ~= nil and player == Owner.Value then local leaderstats = player:FindFirstChild("leaderstats") if leaderstats then local Cookies = leaderstats:FindFirstChild("Cookies") if Cookies then Cookies.Value = Cookies.Value + CookiesGainedPerClick; DisplayIncrease("+"..CookiesGainedPerClick) end end elseif player ~= nil and Owner.Value and CheckCharacter(player.Character) and player.Character.Humanoid.Health > 0 then if CanSteal then if player:FindFirstChild("CanBeStolenFrom") and not player:FindFirstChild("CanBeStolenFrom").Value then player:FindFirstChild("CanBeStolenFrom").Value = true; end if Owner.Value:FindFirstChild("CanBeStolenFrom") and not Owner.Value:FindFirstChild("CanBeStolenFrom").Value then print("can't steal") DisplayIncrease("This player's cookies are secured because they have not stolen."); else local leaderstats = player:FindFirstChild("leaderstats") local leaderstatsOwner = Owner.Value:FindFirstChild("leaderstats") if leaderstats and leaderstatsOwner then local Cookies = leaderstats:FindFirstChild("Cookies") local OwnerCookies = leaderstatsOwner:FindFirstChild("Cookies") if Cookies and OwnerCookies then local StealValue = math.max(CookiesGainedPerClick*2, OwnerCookies.Value * 0.000625 + 0.5) -- Steal 2.5%? StealValue = math.min(StealValue, Cookies.Value/(10 * math.log(Cookies.Value))) -- Limit new player's rise to power. StealValue = math.floor(math.min(math.max(StealValue, 2), 112000)) if OwnerCookies.Value >= StealValue then Add(Cookies, math.floor(StealValue*0.8)) --Cookies.Value = Cookies.Value + math.floor(StealValue*0.8); --OwnerCookies.Value = OwnerCookies.Value - StealValue; Add(OwnerCookies, -StealValue) Stolen = Stolen + StealValue DisplayIncrease(" *stolen* "..StealValue) elseif OwnerCookies.Value >= 1 then Cookies.Value = Cookies.Value + OwnerCookies.Value OwnerCookies.Value = 0 DisplayIncrease("All of "..Owner.Value.Name.."'s cookies got stolen!"); end end end end else DisplayIncrease("Over 30% of this player's cookies have been stolen, wait "..math.floor(60 - (tick()-LastTime)).." secs."); end end end) end detector.MouseClick:connect(MouseClick)