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

Can someone help me debug this?

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)

2 comments

2

Objects accessed by only the server belong in ServerStorage and not Lighting. Objects accessed by both the server and the client belong in ReplicatedStorage.

0

Thanks! ^

1 answer

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)

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