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

(FilteringEnabled) how to use player's PlayerGui children? Still need help, please.

I'm making a sword that has a ClickDetector in it and when it's being triggered I want to put the sword to the player's who clicked PlayerGui.ScreenGui. Since I got FilteringEnabled on the Output tells me that the server can't find ScreenGui in the PlayerGui. I tried scripting it different ways but I couldn't make it to work. Help, please.

The script that's in the sword.

script.Parent.ClickDetector.MouseClick:connect(function()
	game.ReplicatedStorage.RemoteEvent:FireClient()
end)

This is the script that's in the ServerScriptService

game.ReplicatedStorage.Sword.OnServerEvent:connect(function(player)
	game.Workspace.Sword.Parent=player.PlayerGui.ScreenGui
end)

2 comments

0

Why do you need to put the Sword into the ScreenGui?

0

I'm making a RPG. There will be an inventory.

2 answers

The script in the ServerScriptService should be in a local script In StarterGui also we cant exactly set its parent to it so we just clone it and parent it there.

local player = game:GetService("Players").LocalPlayer
local ui = player:WaitForChild("PlayerGui")
game.ReplicatedStorage.Sword.OnClientEvent:connect(function()
	sword = game.Workspace.Sword:Clone()
	sword.Parent = ui.ScreenGui
end)

1 comment

0

oh, now output tells that there's an error in the script that is in the sword "Argument 1 missing or nil"..

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