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

PlayerUI is not a valid member of PlayerGui?

Asked by 5 years ago
Edited 5 years ago

Why is it now working this is my script PLS halp ME

local tool = script.Parent


local Settings = tool:WaitForChild("Settings")
local Strength = Settings.Strength

local Player = game.Players.localPlayer
local PlayerUI = Player:WaitForChild("PlayerGui").PlayerUI

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RemoteEvents = ReplicatedStorage.RemoteEvents
local CoinClicked = RemoteEvents.CoinClicked


local Debounce = false


tool.Activated:Connect(function()
    if Player.PlayerStats.CurrentValue.Value < Player.PlayerStats.Storage.Value then
        if Debounce == false then
            Debounce = true
            CoinClicked:FireServer(Strength.Value)
            wait(0.25)
            Debounce = false
        end
    else
        -- StorageFull Code
     end
 end)
1
It is at StarterGui (this is the parent) FireScythe_User 6 — 5y
1
Your problem is probably one of two things, either the script is trying to access this "PlayerUI" object before its cloned to the player (In that case, do :WaitForChild("PlayerUI") OR you've put PlayerUI in the wrong place or something like that. Psudar 882 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

I'm assuming that when the script is running, at line 8, it's checking for PlayerUI before it has existed at that time (By that I mean before the PlayerUI hasn't been cloned to PlayerGui at the moment the script was running). To fix this, just add another :WaitForChild for PlayerUI like this: local PlayerUI = Player:WaitForChild("PlayerGui"):WaitForChild("PlayerUI")

Ad

Answer this question