Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How Can I Get This Script To Only Be Used Once?

Asked by
jacobwow 140
10 years ago

Here it is:

local Button = script.Parent

function onTouch(Brick)
    local Player = Brick.Parent:findFirstChild("Humanoid")
    if (Player ~= nil) then
        local Location = game:GetService('Players'):GetPlayerFromCharacter(Player.Parent)
    if Location:WaitForChild("leaderstats").Gold.Value >= 20 then
for i = 1,1 do
         Location:WaitForChild("leaderstats").Gold.Value  =  Location:WaitForChild("leaderstats").Gold.Value - 20
        script.Parent.Parent.Name = Player.Parent.Name .. "'s House"
        local Color1 = BrickColor:Random()
        local Color2 = BrickColor:Random()

        script.Parent.Parent.Wall1.BrickColor = Color1
        script.Parent.Parent.Wall2.BrickColor = Color1
        script.Parent.Parent.Wall3.BrickColor = Color1

        script.Parent.Parent.Floor.BrickColor = Color2
        script.Parent.Parent.Head.BrickColor = Color2
        script.Parent.Parent.Roof.BrickColor = Color2
        script.Parent.CanCollide = false
        script.Parent.Transparency = 1
end
        end
    end
end

Button.Touched:connect(onTouch)

Answer this question