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

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

Asked by 5 years ago

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.

1
No, don't handle GUI coding on the server. User#19524 175 — 5y
0
What do you mean? TheOwlFromSaturn 26 — 5y

1 answer

Log in to vote
1
Answered by 5 years ago
Edited 5 years ago
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.

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. Dog2puppy 168 — 5y
0
No. http://wiki.roblox.com/index.php?title=API:Class/ClickDetector User#19524 175 — 5y
Ad

Answer this question