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

how do i fix 16:11:18.310 - er is not a valid member of PlayerGui ?

Asked by 5 years ago

the error: 16:11:18.310 - er is not a valid member of PlayerGui

game.ReplicatedStorage.Transfromgold.UNDOTRANS.OnServerEvent:Connect(function(plr)


local chr = plr.Character
local hum = chr.Humanoid

        for _,none in pairs(hum:GetChildren()) do
            if none:IsA("NumberValue") then
                none:Remove()
            end
        end
        wait(.12)
local waited = plr.PlayerGui.er:WaitForChild("er")
                for _,kill in pairs(waited:GetChildren()) do
                    if kill:IsA("NumberValue") then
                    local copy = kill:Clone()
                    wait(.12)
                        copy.Parent = hum
                    end
                end


end)


end)

the firing script


local tem = "None" local InputService = game:GetService("UserInputService") InputService.InputBegan:Connect(function(input) -- on local key = input.KeyCode if key == Enum.KeyCode.R then game.ReplicatedStorage.Transfromgold.Trans:FireServer() print("fired") end end) ----- InputService.InputBegan:Connect(function(input) local plr = game.Players.LocalPlayer local chr = plr.Character local hum = chr.Humanoid local key = input.KeyCode if key == Enum.KeyCode.E then game.ReplicatedStorage.Transfromgold.UNDOTRANS:FireServer() end end)
0
:Remove() is decaperated, use :Destroy() User#23365 30 — 5y
0
Is "er" inside the PlayerGui? Bloxulen 88 — 5y
0
yeah helleric -3 — 5y

1 answer

Log in to vote
1
Answered by
DanzLua 2879 Moderation Voter Community Moderator
5 years ago

Simple error

Line 13 of the first script provided errors because the WaitForChild() function is being used on the er.

Problem:

local waited = plr.PlayerGui.er:WaitForChild("er")

To fix this we just remove the first er so that we are waiting for er to load in PlayerGui

local waited = plr.PlayerGui:WaitForChild("er")

Complete Script

game.ReplicatedStorage.Transfromgold.UNDOTRANS.OnServerEvent:Connect(function(plr)

local chr = plr.Character
local hum = chr.Humanoid

        for _,none in pairs(hum:GetChildren()) do
            if none:IsA("NumberValue") then
                none:Remove()
            end
        end
        wait(.12)
local waited = plr.PlayerGui:WaitForChild("er")
                for _,kill in pairs(waited:GetChildren()) do
                    if kill:IsA("NumberValue") then
                    local copy = kill:Clone()
                    wait(.12)
                        copy.Parent = hum
                    end
                end


end)

end)
Ad

Answer this question