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

Why is my Remote Event not working for the client?

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?

1 comment

0

Where is your local script located?

2 answers

✓ Accepted answer

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)

6 comments

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.

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.

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.

0

can you provide me with the script

0

else i can make a video on your problem

0

Which script?

Just found out that you can't use :FireClient() and have your event in the ReplicatedStorage. I didn't know that.

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