I made an inventory gui,it works fine on Studio but on my game it doesn't work. It keeps saying onServerEvent can only be fired on servers for example,im using MouseEnter and MouseLeave,that works on my place. But mousebutton1click does not work on my place when i want to use it,only on my studio. script example.
script.Parent.MouseButton1Click:connect(function() frame:TweenPosition(UDim2.new(0.5,-250,0.5,-200),"Out" ,"Quint" ,0.5) print("Test") end
is there any solution to this? as i said,i did not use a single word saying "onServerEvent" on my script. please help me,i asked this before but didn't help.
The reason you are getting the "OnServerEvent can only be fired on servers" is because you are probably using .OnServerEvent
in a LocalScript and this is one of the no no's of RemoteEvents.
If you want to use OnServerEvent, it must be used in a ServerScript.
Think of it as this, ServerScripts(the regular blank blue ones) can only see and run on the server, and LocalScripts can only see what's on the client, and only run on the client (The "client" is your computer and it is the script with the person looking thing on it). Also in tandem with both, ServerScripts can use ServerScript properties and LocalScripts are the same, so this means OnServerEvent (A ServerScript property) cannot be used on a LocalScript, thus giving you your error.
For more info and help i suggest you do some learning on RemoteEvents etc.
Helpful Links!
ScriptGuider's Youtube Video On Remote Events (SUPER HELPFUL)
Very good explanation on LocalScript vs Server script usage : By Link150