I'm trying to take a GUI in lighting to put it in a GUI in the game GUI, but right now, it dosen't seem to work. I don't know what is wrong, and I ask for some of your assistance.
script.Parent.MouseButton1Click:connect(function() local swordSlot = game.Lighting:findFirstChild("linkedSwordSlot") swordSlot.Parent = game.StarterGui.Inventory.Frame:findFirstChild("row1") print("Made the parent row1!") game.StarterGui.Inventory.Frame:findFirstChild("row1").slot1.Parent = game.Lighting print("Success!") end)
Elements of StarterGui are not supposed to be changed, so I assume you mean to change something specifically in the gui of the player who clicked. ClickDetector.MouseClick
gives you the player who clicked, so change the objects in their own PlayerGui
. If filtering is enabled, the server does not have access to client-sided objects such as elements of PlayerGui
, so in that case RemoteEvents
are necessary to inform the client. Otherwise, this is what you meant to write:
script.Parent.MouseClick:connect(function(player) local swordSlot = game.Lighting:findFirstChild("linkedSwordSlot") swordSlot.Parent = player.PlayerGui.Inventory.Frame:findFirstChild("row1") print("Made the parent row1!") player.PlayerGui.Inventory.Frame:findFirstChild("row1").slot1.Parent = game.Lighting print("Success!") end)