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

Why doesn't FireAllClients work when trying to send?

Code: server:

script.Parent.Triggered:Connect(function(player)
	game.ReplicatedStorage.Open:FireAllClients()
	print("A")
end)

Client:

game.ReplicatedStorage.Open.OnClientEvent:Connect(function()
	print("B")
	openDoor()
end)

Output: A (no B)

2 comments

0

Is the client script located in a place where local scripts can run?

0

your remote event is fine. Triggered is not a valid event. I assume you meant script.Parent.Touched

2 answers

FireAllClients Command

When it comes to using the :FireAllClients() feature... I would only use that when you're trying to call to a LocalScript inside of StarterGui/StarterPlayerScripts/StarterCharacterScripts. That's my recommendation but use it as you believe fits. Here's a link that will lead you to how the FireAllClients command works.

Your Error

The error in your script is the script.Parent.Triggered:Connect, after reviewing the script; I realized I missed this MASSIVE mistake. What you need to do is changed Triggered to Touched.

Server Script

script.Parent.Touched:Connect(function(player)
    game.ReplicatedStorage.Open:FireAllClients()
    print("A")
end)

Local Script

Do note that this command may not work if the LocalScript is in workspace, ReplicatedStorage, ReplicatedScriptService, ServerScriptService and ServerStorage.

game.ReplicatedStorage.Open.OnClientEvent:Connect(function()
    print("B")
    openDoor()
end)

1 comment

0

no, just no...

As explained in my comment above...

Server Script

script.Parent.Touched:Connect(function(player) --not Triggered
    game.ReplicatedStorage.Open:FireAllClients()
    print("A")
end)

Local Script

game.ReplicatedStorage.Open.OnClientEvent:Connect(function()
    print("B")
    openDoor() --im assuming you have this function defined somewhere
end)

2 comments

0

FireAllClients() doesn't work unless the script that's collecting thats being called is on the client alone. I've tried using a local script in Workspace, ServerScriptService, ReplicatedStorage, ReplicatedScriptService and so on. It doesn't work that way; you should at the least advise the OP to only use :FireAllClients() for scripts/functions that are in local scripts for strictly that player.

0

Also, instead of saying no, just no...; you should give a proper reason why you give something a downvote. I know what I messed up on and i'm fixing the issue after this post. As a Community Moderator Voter; you should be use to this by now. No, i'm not trying to cause issues but telling you some flaws about your answer. Last thing; I'd remove your comments and move them into your answer.

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