Im trying to make a admin Gui that can Delete other players pet but i cant seen to get info about there gui
its just saying ‘attempt to index nil with ‘PlayerGui’’
i have tried to use local scripts and scripts but i cant get it to work
Local Script:
local player = game:GetService("Players").LocalPlayer
script.Parent.MouseButton1Click:Connect(function()
script.Name = script.Parent.Name
script.Parent.Parent.Parent.Parent.CurrentPlayer.Text = script.Name
local Gplayer = game.Players:FindFirstChild(script.Name)
for i, v in pairs(Gplayer:GetChildren()) do
print(v)
end
for i, v in pairs(player.PlayerGui.Admin.Main.Pets:GetChildren()) do
v:Destroy()
end
for i, v in pairs(Gplayer:FindFirstChild("PlayerGui").PetInv.Pets.ScrollingFrame:GetChildren()) do --NEED TO BE SCRIPT NOT LOCAL SCRIPT CUS I CANT CHECK OTHER POEPLE INSIDE
local PetClone = v:Clone()
PetClone.Parent = player.PlayerGui.Admin.Main.Pets
if PetClone:IsA("ImageButton") then
PetClone.Equipped:Destroy()
end
end
for i, v in pairs(player.PlayerGui.Admin.Main.Pets:GetChildren()) do
local CS = game:GetService("ReplicatedStorage").Gui.Template.PetDelete:Clone()
if v:IsA("ImageButton") then
CS.Parent = v
end
end
end)
Hello! As client you can not see other client’s scripts & UI. This means that PlayerA can not see PlayerB UI nor starter scripts. The way to “bypass” this is by sending a remote from client to server, where you can see PlayerGui. Hope this helps. If you need any more help on this, let me know!
i have already tried that but it keeps giving me index nil
Sorry what do you mean? The drawing below is to visualize what I mean.
i have tried to use remote event from local to server back to local and i getting Index nil
PlayerA is trying to get PlayerB info Back to PlayerA
Can I see your script for doing that?
Basically, as client you can not see other client info. If you send a remote to the server, the server can “see it for you” and return information of B.
Local Script
local player = game:GetService("Players").LocalPlayer
local Event = game.ReplicatedStorage.InfoAdmin
script.Parent.MouseButton1Click:Connect(function()
local PlayerB = game.Players:FindFirstChild(script.Parent.Name)
Event:FireServer(PlayerB)
Event.OnClientEvent:Connect(function(PlayerA, GuiInfo)
print(GuiInfo)
end)
Server Script;
local Event = game.ReplicatedStorage.InfoAdmin
Event.OnServerEvent:Connect(function(PlayerA, PlayerB)
local GuiInfo = PlayerB:FindFirstChild("PlayerGui")
Event:FireClient(PlayerA, GuiInfo)
end)
the output is nil
Hello some feedback on your script!
First of all, you have an event & function within an event & function, you want to avoid that. Change your local script to:
local player = game:GetService("Players").LocalPlayer
local Event = game.ReplicatedStorage.InfoAdmin
script.Parent.MouseButton1Click:Connect(function()
local PlayerB = game.Players:FindFirstChild(script.Parent.Name)
Event:FireServer(PlayerB)
end)
Event.OnClientEvent:Connect(function(PlayerA, GuiInfo)
print(GuiInfo)
end)
Next, if you use :FireClient()
you are passing in to who (Player
) and your parameters. So on the server side you did it correctly, however on the client side you did it wrong. Change it to this:
local player = game:GetService("Players").LocalPlayer
local Event = game.ReplicatedStorage.InfoAdmin
script.Parent.MouseButton1Click:Connect(function()
local PlayerB = game.Players:FindFirstChild(script.Parent.Name)
Event:FireServer(PlayerB)
end)
Event.OnClientEvent:Connect(function(GuiInfo)
print(GuiInfo)
end)
This should just work fine. Keep in mind if you now change the UI on PlayerA it won’t show up for PlayerB, that is because you are only changing it locally, on your client. So if you want to do UI modification you should do that on server side / PlayerB’s client.
Hi so i tried these scripts but im keep getting index nil as a output when using it