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

Script Works Perfectly in one part but not the other?

Asked by 9 years ago

So I made a part that fades in a notification when you touch it, and it works perfectly

So I made another textlabel with a different name and made another part that notifies for something else

When I touch the block one script in it works but not the notification script

Here's the ****WORKING**** code

local buttonPressed = false


script.Parent.Touched:connect(function(hit)
if not buttonPressed then


        buttonPressed = true


    if hit and hit.Parent and hit.Parent:FindFirstChild("Humanoid") then
        character = hit.Parent
        player = game.Players:GetPlayerFromCharacter(character)
        notice = player.PlayerGui.Notices.BranchNotice

    for i = 1,0, -0.1 do
        wait(0.1)
        notice.Text = "You Found a Branch"
        notice.BackgroundTransparency = i
        notice.TextTransparency = i
        notice.ImageLabel.ImageTransparency = i

end

    wait(1.5)

    for i = 0,1, 0.1 do
        wait(0.1)

        notice.BackgroundTransparency = i
        notice.TextTransparency = i
        notice.ImageLabel.ImageTransparency = i
        notice.Text = ""


    end
            wait(1)


        buttonPressed = false
    end
    end
    end)

Here's the second one that ****DOESN'T**** work

local buttonPressed = false


script.Parent.Touched:connect(function(hit)
if not buttonPressed then


        buttonPressed = true


    if hit and hit.Parent and hit.Parent:FindFirstChild("Humanoid") then
        character = hit.Parent
        player = game.Players:GetPlayerFromCharacter(character)
        notice = player.PlayerGui.Notices.BucketNotice

    for i = 1,0, -0.1 do
        wait(0.1)
        notice.Text = "You found a Bucket of Water"
        notice.BackgroundTransparency = i
        notice.TextTransparency = i
        notice.ImageLabel.ImageTransparency = i

end

    wait(1.5)

    for i = 0,1, 0.1 do
        wait(0.1)

        notice.BackgroundTransparency = i
        notice.TextTransparency = i
        notice.ImageLabel.ImageTransparency = i
        notice.Text = ""


    end
            wait(5)


        buttonPressed = false
    end
    end
    end)

I think the only differences are the names, but that might be the problem, but I can't find any. There are no errors either

Answer this question