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

My Tool GUI script doesn't work correctly, how to fix that?

Asked by
kapipi12 133
5 years ago

I've got problem with my script. I was trying to make it like when I equip rod, it shows gui but when i stand on "pomost" and click rod, it changes text but it doesn't work. Can someone explain me what's wrong and how to fix that?

local rod = script.Parent
local pomost = game.Workspace.PomostLvl1
local db = false
local timer = 3
local gui = rod:WaitForChild("ScreenGui")
-- Fish1 percentage is 30%
-- Fish2 percentage is 70%

rod.Equipped:Connect(function()
    char = script.Parent
    player = game.Players:GetPlayerFromCharacter(char)
    gui.Parent = player:WaitForChild("PlayerGui")
end)
rod.Unequipped:Connect(function()
    char = script.Parent
    player = game.Players:GetPlayerFromCharacter(char)
    player:WaitForChild("PlayerGui"):WaitForChild("ScreenGui").Parent = script.Parent
end)

pomost.Touched:Connect(function()
    rod.Activated:Connect(function()
        if(timer == 0) then
            if(db == false) then
                db = true
                if math.random(0, 100) <= 30 then
                    print("You catched fish number 1!")
                    script.Parent.ScreenGui.Frame.TextLabel.Text = "Fish1"
                    print (script.Parent.ScreenGui.Frame.TextLabel.Text)
                    db = false
                    timer = 1
                else
                    print("You catched fish number 2!")
                    script.Parent.ScreenGui.Frame.TextLabel.Text = "Fish2"
                    print (script.Parent.ScreenGui.Frame.TextLabel.Text)
                    db = false
                    timer = 1
                end
            end
        end
    end)
end)

while 1 do
    if (timer == 0) then
        wait(5)
    else
        timer = timer - 1
        wait(1)
    end
end
1
Why is 1 your condition of your whole loop User#19524 175 — 5y
1
The loop doesn't matter here, I was asking about GUI fix. kapipi12 133 — 5y
0
"char = script.Parent" "rod = script.Parent" and the rod is the tool? dude im pretty sure you meant "char = script.Parent.Parent" or something DaCrazyDev 444 — 5y
0
to me it looks like the script needs to be indented correctly. AnotherPerson_999 28 — 5y

Answer this question