hi i am making a game where you would buy proprieties and own them for a duration and while you own it you will be paid the amount in the code. My problem is i have put the "while true do" loop in the code and cant seem to get the code to go past it and it just keeps giving money. how would i fix this? Thank you all for your help.
local Duration = script.Parent.Duration.Value
local Owner = script.Parent.Owner
local pole = script.Parent.Pole
local Banner = script.Parent.Banner
Owned = false
function onClicked(player)
local money = player.leaderstats.Money
if money.Value >= 100 then
money.Value = money.Value - 100
Owned = true
Owner.Value = player.Name
pole.Transparency = 1
Banner.Transparency = 1
while Owned == true do
money.Value = money.Value + 1
wait(1)
end
wait(Duration)
Owned = false
Owner = "None"
pole.Transparency = 0
Banner.Transparency = 0
Owner = "None"
end
end
script.Parent.ClickDetector.MouseClick:connect(onClicked)

1 comment
If this helped, make sure to mark this question as answered!