I am new to RemoteEvent
's and trying to experiment how to use them, can someone tell me why this script work's in Studio
but not in a actual game server, and tell me how to fix it?
Script to fire it:
local plr = script.Parent.Parent.Parent.Parent local event = game.ReplicatedStorage.RemoteEvent script.Parent.MouseButton1Click:connect(function(plr) event:FireServer() end)
Script for when it's fired:
local event = game.ReplicatedStorage.RemoteEvent event.OnServerEvent:connect(function(args) local m = Instance.new("Message",workspace) m.Text = math.random(100,999) end)
In the ServerSided script, line 3. Remove the parameter args
. Since you never put any arguments/parameters when you FireServer(), you don't need any parameters there. Also, the script to fire it. Line 5, remove the parameter plr
.
So:
Script to fire:
local event = game.ReplicatedStorage.RemoteEvent script.Parent.MouseButton1Click:connect(function() event:FireServer() end)
OnServerEvent:
local event = game.ReplicatedStorage.RemoteEvent event.OnServerEvent:connect(function() local m = Instance.new("Message",workspace) m.Text = tostring(math.random(100,999)) -- Just to be safe, use tostring. end)
Hope I helped! Any further questions/comments/errors? Be sure to comment!