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

Filtering enabled script cant find a gui in player gui thats in startergui why is that?

This works find in studio but doesnt in game. I jsut got into filtering enabled and im confused, I followed the wiki and follow youtube videos but it doesnt make sense as to why this isnt working.

This is the script I put in start character (its a local script) ~~~~~~~~~~~~~~~~~

workspace.button5.ClickDetector.MouseClick:connect(function() local ReplicatedStorage = game:WaitForChild("ReplicatedStorage")

ReplicatedStorage.Open:invokeServer()

end)








This is the second script thats in server script service ~~~~~~~~~~~~~~~~~
ReplicatedStorage = game:WaitForChild("ReplicatedStorage")






local function gui(player)
	
	
	
	
	player.PlayerGui.ok.Frame.Visible = true
	
end

ReplicatedStorage.Open.OnServerInvoke = gui





Now in studio it works, but in game it doesnt, It says that it isnt a member of the player Gui, I even tried printing the gui in game using the devleoper tab and it wouldnt print it. When I did a WaitForChild() command for the gui, it said "possible for infinite" which is saying it may go on forever waiting, which it does because it doesnt work.

2 comments

1

No, don't handle GUI coding on the server.

0

What do you mean?

1 answer

✓ Accepted answer
Problem Solution
You're using a RemoteFunction and not returning anything Use a RemoteEvent instead
You're modifying PlayerGui from the server Modify from client instead
You're handling MouseClick on the client Handle on the server

###Final product

-- LocalScript under ok.Frame

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local OpenGui = ReplicatedStorage:WaitForChild("Open")

OpenGui.OnClientEvent:Connect(function()
    script.Parent.Visible = true
end)

………

-- Server Script under button5

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local OpenGui = ReplicatedStorage:WaitForChild("Open")

script.Parent.ClickDetector.MouseClick:Connect(function(plr)
    OpenGui:FireClient(plr)
end)

###On a side note:

###You should never guess on which remote you should use. Use a RemoteFunction if you want to return something, such as the price of a car in game. Use a RemoteEvent if you want to do something such as spawning a car.

2 comments

0

But why handle the MouseClick on the server? It'll just cause input lag, and since all it's doing is opening a gui, it can all be client sided.

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