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

Filtering Enabled clicker help?

Asked by 4 years ago
Edited 4 years ago

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

0
I have edited my response with what is likely the culprit. Just an extra set of parentheses. TheIndigoNight 40 — 4y
0
Why not put a server script inside of the button and run everything inside the same script when the button is pressed? ISeeChase2 14 — 4y
0
well, its going to be putting money into the person and i want it to be filtering enabled guywithapoo 81 — 4y
0
I fixed what I was supposed to fix and now it is saying that RemoteEvent is not even a child of ReplicatedStorage but it is. guywithapoo 81 — 4y
View all comments (2 more)
0
Being that you are using a local script, you may need to add a WaitForChild for RemoteEvent. See: https://developer.roblox.com/en-us/api-reference/function/Instance/WaitForChild TheIndigoNight 40 — 4y
0
yeah i actually did that and still getting issues you know what you can just drop this question im not getting anything out of it and im irritated lmao guywithapoo 81 — 4y

1 answer

Log in to vote
1
Answered by 4 years ago
Edited 4 years ago

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.

0
thanks, I will try to implement this guywithapoo 81 — 4y
0
did not work read my edit guywithapoo 81 — 4y
Ad

Answer this question