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)
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)
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.
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.
script.Parent.Touched:Connect(function(player)
game.ReplicatedStorage.Open:FireAllClients()
print("A")
end)
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)
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)
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.
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.
2 comments
Is the client script located in a place where local scripts can run?
your remote event is fine.
Triggeredis not a valid event. I assume you meantscript.Parent.Touched