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

Why Does This First Script Work But The Other Doesn't Work?

Asked by
jacobwow 140
10 years ago

First Script:

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 = "Yay"
        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
end
        end
    end
end

Button.Touched:connect(onTouch)

Second Script :

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 .. "'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
end
        end
    end
end

Button.Touched:connect(onTouch)

0
difference is in line ten jacobwow 140 — 10y

1 answer

Log in to vote
3
Answered by
HexC3D 830 Moderation Voter
10 years ago
 script.Parent.Parent.Name = Player.Name .. "'s House"

if this helped +1, and if it answered check mark :)

Ad

Answer this question