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

onServerEvent can only be fired on servers error??

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.

4 comments

0

You obviously have some buggy code in your game that is using RemoteEvents. You need to find it and ERADICATE it :P

0

I only have a inventory GUI script.I havent used a single word saying remote event on it..

0

Do CTRL+Shift+F then search for 'RemoteEvent' or 'OnServerEvent'.

0

nevermind,it was a buggy code just as you said,thank you.

1 answer

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

RemoteEvents and Functions

ServerScripts

LocalScripts

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