Hello, I have been trying to do something for a while but I cant seem to make it work, so I tried something easier but it still wont work. I have a part called "clicker" in Workspace with a ClickDetector inside. Then, in ReplicatedStorage I have a RemoteEvent that is just called RemoteEvent. Inside of ReplicatedFirst I have a LocalScript that is supposed to know when "clicker" is clicked. the final addition is the regular script in Workspace that is used to print something when the button is pressed. I get as an error, "Argument 1 missing or Nil"
Here is the localscript in ReplicatedFirst:
local Players = game:GetService("Players") local ReplicatedStorage = game:GetService()("ReplicatedStorage") local player = game.Players.LocalPlayer game.Workspace.clicker:WaitForChild("ClickDetector").MouseClick:Connect(function() ReplicatedStorage.RemoteEvent:FireServer() end)
Here is the script in Workspace:
game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function() print("button pressed") end)
EDIT: Ok so I tried changing it for what TheIndigoNight said, but I still get the same error.
The localscript is now in ReplicatedStorage and is as follows:
local Players = game:GetService("Players") local ReplicatedStorage = game:GetService()("ReplicatedStorage") local player = game.Players.LocalPlayer ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function() print("clicked") end)
And the regular script is now inside of clicker:
script.Parent.ClickDetector.MouseClick:Connect(function() game.ReplicatedStorage.RemoteEvent:FireClient() end)
IT STILL DOESNT WORK PLEASE HELP
So a few things:
1: RemoteEvent:OnServerEvent expects a player argument. This is likely the issue for the error message. See: https://developer.roblox.com/en-us/api-reference/event/RemoteEvent/OnServerEvent
2: You may want to simplify this entire process eliminating the need for remote events alltogether by doing the click detector inside of a Script instead of a Local Script. The docs say that the click detector will work with scripting enabled on with both Scripts and Local Scripts. See: https://developer.roblox.com/en-us/api-reference/class/ClickDetector
Opinion: Personally I would go with option 2 and send remote events to the client using it if needed. I like to minimize the amount of Local Scripts and the amount of code they use.
Edit: I found another issue in line 2 of your Local Script. Your code:
local ReplicatedStorage = game:GetService()("ReplicatedStorage")
Fixed code:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
You had an extra set of parentheses. Hope this helps.