Ad
Log in to vote
0

Why is my Remote Event not working for the client?

Asked by 19 days ago

I am trying to make a game where you need to press a button to unlock an exit. The button model I am using has a ClickDetector inside of it. I also have a Script, RemoteEvent, and LocalScript inside as well. I tried to program my Script to fire the RemoteEvent on the Client. Then, my LocalScript will receive that Client Fire and will make the button turn green, and unlock the Exit for ONLY the player who clicked the button. Not the whole server.

The thing is, when I run the game and click the button, it doesn't do anything and gives me this Output Error:

 Argument 1 missing or nil  -  Server - Script:2

This is the code for the ClickDetector Script (The Normal Script):

script.Parent.ClickDetector.MouseClick:Connect(function(player)
    script.Parent.ButtonEvent:FireClient()
end)

This is the code for the LocalScript (The Client Receiver Script):

script.Parent.ButtonEvent.OnClientEvent:Connect(function()
    script.Parent.BrickColor = BrickColor.new("Lime green")
end)

I have also tried making the Normal Script turn the button Green, but it happens for the whole server (which I don't want).

Any help on this?

0
Where is your local script located? SimpleFlame 210 — 19d

1 answer

Log in to vote
0
Answered by 19 days ago

Hello,

You have made a mistake in the argument of the Server Script that you haven't defined which Player the server will trigger the event for. The FireClient() should have the first Parameter of FireClient(Player) (Player). This would be like,

Code Example, Triggering Remote Event to Client


script.Parent.ClickDetector.MouseClick:Connect(function(player)
    script.Parent.ButtonEvent:FireClient(player)  <--
end)

0
Hi_People1133 I have tried this before and it still dosn't work. Except, when I do it this way it dosn't give me any errors in the output. It just dosn't work. JackYT_gaming123 6 — 19d
0
It should work, it works for everyone and should for you, the debugging method was invented just for solving out errors in scripts, you can find errors by putting print() in multiple lines in your script. if it doesn't print it indicates the location of error. Hi_People1133 168 — 19d
0
I just made the Normal Script print "Robux" when it is activated and it works. However, I tried to make the LocalScript say "Robux 2" in the output when it receives the ClientEvent, but it dosn't do anything. JackYT_gaming123 6 — 19d
0
can you provide me with the script Hi_People1133 168 — 19d
View all comments (2 more)
0
else i can make a video on your problem Hi_People1133 168 — 19d
0
Which script? JackYT_gaming123 6 — 19d
Ad

Answer this question