Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Can someone help me debug this?

Asked by 8 years ago

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
Objects accessed by only the server belong in ServerStorage and not Lighting. Objects accessed by both the server and the client belong in ReplicatedStorage. 1waffle1 2908 — 8y
0
Thanks! ^ KennySfromTitan 106 — 8y

1 answer

Log in to vote
1
Answered by
1waffle1 2908 Trusted Badge of Merit Moderation Voter Community Moderator
8 years ago

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)
Ad

Answer this question