Remote Event Not Working?

Hello There! I am Trying to Fire A Remote event to the Server But Its Simply Not Working.

Here, Its A Little Different. I Made a remote Event in Replicated Storage and Called It
LockOpened

Now Heres A Script.

 local Deb = false

script.Parent.ClickDetector.MouseClick:Connect(function(player)
	if player:WaitForChild("Backpack"):FindFirstChild("Key") and Deb == false then
		Deb = true
			game.Workspace.Sounds.LockOpen:Play()
		wait(2.5)
		FireClients(player)
			script.Parent:Destroy()
		else
			game.Workspace.Sounds.LockedDoor:Play()
	end
end)

function FireClients(player)
	game.ReplicatedStorage.LockOpened:FireAllClients(player)
end

In the Above Script,The script.Parent Is A Part Which In My Game, Acts as A Door Lock.
When you Click It, It checks If the Player who clicked It has A “Key” in their Backpack Or Not. If They Do, Then It Fires a Remote Event To A Local Script Which Further Fires it to a Script in ServerScriptService

The Problem Is that The Above Script Does not Even Fire The Remote Event to The Client.It Destroys The Lock Part As i have the Key In my Backpack but does not Fire The Remote Event.

Long Story Short, The Above Script is MEANT To Fire Clients But Does not.

The Script Above is A SCRIPT and Not A Local Script

Please Help!

There are two things wrong here

FireClients(player)

You are trying to call a function that the line cannot recognize because the function you are trying to call is ahead of the line.

game.ReplicatedStorage.LockOpened:FireAllClients(player)

You don’t necessarily need to put the player instance as a parameter.

This should fix it:

 local Deb = false

function FireClients(player)
	game.ReplicatedStorage.LockOpened:FireAllClients(player)
end

script.Parent.ClickDetector.MouseClick:Connect(function(player)
	if player:WaitForChild("Backpack"):FindFirstChild("Key") and Deb == false then
		Deb = true
			game.Workspace.Sounds.LockOpen:Play()
		wait(2.5)
		FireClients(player)
			script.Parent:Destroy()
		else
			game.Workspace.Sounds.LockedDoor:Play()
	end
end)

This Script Does not Work. I Tested It Out.

Any errors on the output? If so, can you show me the error?

No Errors In the Output As far As I See.

Can I see the local script? Maybe the issue starts there.

Nvm I fixed my Issue. I just dint use remote Events. I managed everything in one script Itself Which Works. But Anyways If You Want to Still fix the Issue like know why that Firing was not working, Here is the Local Script.

If You Do find The Cause which was Preventing my Script to work. I would surely mark It as A Solution.



game.ReplicatedStorage.LockOpened.OnClientEvent:Connect(function(player)
	game.ReplicatedStorage.LockOpened:FireServer(player)
end)

Have you considered getting the remote to fire from the client without the server telling it to? (FireClients)
If yes, why have you chosen to do it the way you did? Asking this mostly out of curiosity, since you already fixed the issue.

I am Making a Story Game. The Story Scripts And What Happens in the Game is All Managed in a Single Script in ServerScriptService.

I Simply wanted to Use Remote Events to Keep Everything in A Single Script.
So A Remote Event fires To a Server or Something and Everything is Handled In the Server.