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

why wont my script find the things inside playergui?

i made a chat script that teleports me to a friend when i type a command out but it says that chat is not a valid memeber of playergui any idea on how to fix this?

if game.Players:FindFirstChild("kleppolek") then

if game.Players.kleppolek.PlayerGui.ChatFrame.ChatBarParentFrame.Frame.BoxFrame.Frame.ChatBar.Text == "/me wk" then

game.Players.klepplek.Character.HumanoidRootPart.CFrame = CFrame.new(game.Workspace.world_kiIIer.Head.Position)

end

end

if game.Players:FindFirstChild("world_kiIIer") then

if game.Players.world_kiIIer.PlayerGui.Chat.Frame.ChatBarParentFrame.Frame.BoxFrame.Frame.ChatBar.Text == "/me klep" then

game.Players.world_kiIIer.Character.HumanoidRootPart.CFrame = CFrame.new(game.Workspace.kleppolek.Head.Position)

end

end

also when we tested the game in roblox servers it said that player gui is not a valid member of payer, why? this is a local script inside starterpack

2 comments

0

I read on one of the answers on here once that "The server cannot see the descendants of playergui which is clientside" or so I think

0

the script is a client side and so is the playergui so it should see

1 answer

Hello! I'm BlackOrange3343 and I'll be helping you today.

A ServerScript is incapable of accessing the PlayerGui of a Player. In order to access the PlayerGui, you must use the Client in this case a LocalScript. If you wish to start from the server, then you must use a RemoteEvent to signal the Client to change what you want to change.

To fix this:

  1. Add a LocalScript to the client and make sure it can run and access the GUI.

Now in the Local Script:

local ReplicatedStorage = game:GetService('ReplicatedStorage')

ReplicatedStorage.RemoteEvent.OnClientEvent:Connect(function()
	-- Do Stuff here that you wanted to do
end)

and in the Server Script under the command line where you check if the command is correct do:

local RemoteEvent = Instance.new('RemoteEvent')
RemoteEvent.Parent = game.ReplicatedStorage
RemoteEvent:FireClient(Player) -- Make sure Player argument is actually 
game:GetService('Debris'):AddItem(RemoteEvent, 1)

With this, you are now able to communicate to the client from the server. Now you can adjust the code accordingly.

Hope this helped! Best of luck developer!

BlackOrange3343

PS: If it errors please comment the error.

2 comments

0

i dont need remotes, its a client script with a local script, it just moves me to the other player location

0

You should still use a RemoteEvent and use the command on the server.

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