Because it doesn’t read me what is inside the test folder
localscript
local y = script.Parent.Parent.Parent
script.Parent.MouseButton1Click:Connect(function()
script.Parent.Parent.ImageButton:Clone().Parent = script.Parent.Parent.Parent.test
game.ReplicatedStorage.RemoteEvent:FireServer(y)
end)
script
game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(y)
for o,q in pairs(y:GetChildren()) do
if q.Name == "PlayerGui" then
for o,w in pairs(q:GetChildren()) do
if w.Name == "test" then
for o,e in pairs(w:GetChildren()) do
print(e)
end
end
end
end
end
end)
On the server side, when you’re calling the remote using OnServerEvent, the first argument must be the player, so try to do game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(player) [if you only need the player]
It looks like you’re passing an argument on the local side, so it means you have to have 2 arguments in the server side
and on the client try this -
local y = script.Parent.Parent.Parent
local replicated = game:GetService("ReplicatedStorage")
local remote = replicated:WaitForChild("RemoteEvent")
script.Parent.MouseButton1Click:Connect(function()
script.Parent.Parent.ImageButton:Clone().Parent = script.Parent.Parent.Parent.test
remote.RemoteEvent:FireServer()
end)
If you have n arguments in the FireServer(), you must have n+1 arguments in the OnServerEvent(),
apparently it doesnt look like he need that ‘y’, he can access the player’s GUI even without it
I can’t even figure out the issue because nothing tells you what the variables are and is just nameing it with singular letters so I am unable to help in the situation.
local y = script.Parent.Parent.Parent
local replicated = game:GetService("ReplicatedStorage")
local remote = replicated:WaitForChild("RemoteEvent")
script.Parent.MouseButton1Click:Connect(function()
script.Parent.Parent.ImageButton:Clone().Parent = script.Parent.Parent.Parent.test
remote.RemoteEvent:FireServer()
end)
script
game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(player, y)
for o,q in pairs(y:GetChildren()) do
if q.Name == "PlayerGui" then
for o,w in pairs(q:GetChildren()) do
if w.Name == "test" then
for o,e in pairs(w:GetChildren()) do
print(e)
end
end
end
end
end
end)
From what it seems like you’re trying to access the PlayerGui from player by .Parent. If you want to access the player from a LocalScript you can just use game:GetService("Players").LocalPlayer. - access player locally
But since the player is already passed in the function parameter connected to the RemoteEvent.OnServerEvent by default you can define the PlayerGui on the server instead with local PlayerGui = player:WaitForChild("PlayerGui")- get the PlayerGui with player trough the function parameter
So technically the OnServerEvent will look like this (player) even though you won’t see it. - then of course you can pass other arguments in the parameter
So to get the “test” instance in your PlayerGui you can simply do
game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(player) -- if y is player then player is the same as y to clarify
local PlayerGui = player:WaitForChild("PlayerGui") -- define the PlayerGui in the variable
if PlayerGui then -- if you really want to make sure it exists
for index, instance in pairs(PlayerGui:GetChildren()) do
if instance.Name == "test" then
for a, child in pairs(instance:GetChildren()) do
print(child)
end
end
end
end
end)
This script should get the PlayerGui and scan it for “test” then get the Children of “test” and print them out in the console.
If you want to do that locally you can get the “test” by doing this
local Players = game:GetService("Players")
local PlayerGui = Players.LocalPlayer:WaitForChild("PlayerGui")
PlayerGui.ChildAdded:Connect(function(Child)
if string.match(Child.Name, "test") then
for index, instance in pairs(Child) do
-- not knowing where your SurfaceGui is makes it difficult to provide you with an accurate example
end
end
end)
This snippet checks every child that is added to the PlayerGui and if the name of child is “test” then it will get the children of “test”. Then you need to locate your SurfaceGui and if you want to duplicate them you can do.
local clone = instance:Clone()
clone.Parent = --SurfaceGui
Also make sure to set Visible of instance to true if it isn’t already set to true.