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

I want a UI to pop up, however it doesn't happen. What did I do wrong?

Asked by 7 years ago
Edited 7 years ago
local plr = game.Players.LocalPlayer
local rp = game:GetService('ReplicatedStorage')
local notification = game.StarterGui.Notification

script.Parent.MouseButton1Click:connect(function()
    if plr.Backpack:FindFirstChild('PirateSword') or plr.StarterGear:FindFirstChild('PirateSword')or
        game.Workspace[plr.Name]:FindFirstChild('PirateSword') then
        notification.Base.Visible = true
        notification.Base.Text = 'You Already Purchased This'
        wait(1.5)
        notification.Base.Visible = false

    else
        if plr.leaderstats.Coins.Value >= 50 then
            rp.PirateSword:Clone().Parent = plr.Backpack
            rp.PirateSword:Clone().Parent = plr.StarterGear
            plr.leaderstats.Coins.Value = plr.leaderstats.Coins.Value - (50)

        else
            local cashrequired = 50 - plr.leaderstats.Coins.Value
            notification.Base.Visible = true
            notification.Base.Text = 'You Need '..cashrequired..' More Coins To Buy This!'
            wait(1.5)
            notification.Base.Visible = false
        end
    end
end)
0
The entire code has to go in between the two long "~~~~~~" lines so the code can be formatted correctly in Lua. xPolarium 1388 — 7y
0
Ty just realized SenseiPrince 16 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago

When player joins the game, folder where all his guis are kept is named PlayerGui. Path to your notification will be:

game.Players.LocalPlayer.PlayerGui.Notification

so with your variable it will be:

plr.PlayerGui.Notification
0
Thank you so much, I don't know why I didn't realize ... SenseiPrince 16 — 7y
Ad

Answer this question