Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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)





3 comments

0

:Remove() is decaperated, use :Destroy()

0

Is "er" inside the PlayerGui?

0

yeah

1 answer

✓ Accepted answer

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)

This discussion is preserved as it was. New answers, comments, and votes are closed.