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

Script in ServerScriptStorage fires errors when playing in-game, but works in Studio?

Asked by
Felktor -8
6 years ago
Edited 6 years ago

I have a script, remotefunction, etc. that open a shop when you right click on a part, that works perfectly in studio, but I always get the same errors in-game! Could someone please assist me?

The error I get in-game: https://gyazo.com/c152f5a990f8826a43c92aa69846ce8b

What it should look like when I buy it: https://gyazo.com/0a29e9f208e8e2d37e877904ebfef2db

The code basically opens the menu when the remoteevent is fired and IS STORED IN SERVERSCRIPTSTORAGE

This is the code that is getting the error:

local open= game.ReplicatedStorage.menuEvent
open.OnServerEvent:connect(function(plr, id)
    repeat wait() until plr.PlayerGui.Main~= nil
    plr.PlayerGui.Main.Frame.Value.Value=id 
    plr.PlayerGui.Main.Frame.Visible=true
end)

Client sided (fires the event):

children=workspace.Planets:GetChildren()
for i=1, #children do
children[i].detect.ClickDetector.RightMouseClick:connect(function()
    print"db"
    game.ReplicatedStorage.menuEvent:FireServer(children[i].Name)
    print"debug"
end)
end

Please help!

0
The server can't access the descendants of the players' playerguis when fe is enabled. It's best to do it in a localscript. You should paste the client - sided part of the script too Rare_tendo 3000 — 6y
0
Alrighty Felktor -8 — 6y

1 answer

Log in to vote
0
Answered by
Felktor -8
6 years ago

Thanks for the comment, chexy. After reading that I realized how redundant the whole thing was, so I moved it all to clientside and it now works, thank you!

-Green

0
np Rare_tendo 3000 — 6y
Ad

Answer this question