result:FireAllClients() does not work after some testing. I tried this part of a script just to test a theory of mine and it did not work either, proving my theory.
local test = game.ReplicatedStorage.Minigames:GetChildren()
test:FireAllClients()
Even though the child is a remote event firing all clients on the child of Minigame does not work.
I’ll likely need some way to find out what result is each time and make a direct reference to it like local test2 = game.ReplicatedStorage.Minigames["Ball Race"].
In that script, the variable test is not a single event, it’s a list. GetChildren() returns a list of children, FindFirstChild() returns a single child.
I’ve set up a basic test on my end. It’s three things:
Server script:
wait(5) --give the client time to load before we fire it
game.ReplicatedStorage.Minigames:FindFirstChild("Ball Race"):FireAllClients()
Client script:
local event = game.ReplicatedStorage.Minigames["Ball Race"]
local function Trigger()
print("It worked!")
end
event.OnClientEvent:Connect(Trigger)
It worked for me, so using FindFirstChild with FireAllClients works fine.
No matter what I do nothing works. It won’t print “It worked!”. I’ve tried game.ReplicatedStorage.Minigames:FindFirstChild("Ball Race"):FireAllClients() but it doesn’t work.
I’d suggest stepping through the things your script needs to do one at a time, with a bunch of print statements for good measure. Have your code print randomGame.Name, see what it’s searching for.
Also, make sure you give your client enough time to load before you fire your test event. I consider 3 seconds to be safe, but usually allow 5 just in case Roblox feels like being slow on that test run.
Taking a look at your script, you don’t need to use :FindFirstChild() to find the remote event, as you have already gotten it when defining the randomGame variable. You should be able to do:
randomGame:FireAllClients()
Please don’t do this, do: game.ReplicatedStorage.Minigames:WaitForChild(“Ball Race”) instead. This makes sure the remote event is ready at the minimum time delay.
I also highly do not recommend putting spaces in names as this makes it much more complicated to get instances in scripts.
If I were to continue to use RandomGame then it would be random every time, which would be a problem. I added a space because I’m setting the name of it to the text of a text label. The whole idea is that it chooses a random option and then fires the right remote event.
No, this isn’t always the case, the way variables work is they return an instance instead of redoing the function. This means the returned variable will always return the same until it is defined again. For example:
local number = math.random(1,1000)
print(number) --974
print(number) --974
number = math.random(1,1000) --redefining the variable
print(number) --275
That won’t work. Waiting for the child to load on the server side does not guarantee that the client has loaded, which is where the print statement we’re using to debug comes from. If you care about it, you can wait for a player to join and then fire the event, but I wanted something that was simple and removed all possible sources of error.
Apologies, I did not fully understand the topic. If you want it to wait until the client has responded, you can use a remote function. Remote Functions are different as they do wait for a response unlike remotevents.
A solution is not needed for anything, just an indicator for other developers that the topic no longer needs support. If you absolutely want a solution, what was the final reply that helped you solve the problem?
local votingOption = game.Workspace.VotingSpace1.VotingOption1
local folder = game.ReplicatedStorage.Minigames
local folderName = votingOption.Name
task.wait(5)
for i,v in ipairs(folder:GetChildren()) do
if v.Name == folderName then
print("Test worked")
return v
end
end
It didn’t end up working. I don’t know if this would be because the name of the folder changes.
local event = game.ReplicatedStorage.Minigames["Ball Race"]
local function Trigger()
task.wait(5)
print("It worked!")
end
event.OnClientEvent:Connect(Trigger)
you seems to be using multiple events for the voting system . why not change it to one? you can just use one to fire from server to client to tell the client what choice it have . then you can use the same event for sending the name of the map that the client chose …
It’s not that I’m lazy (clearly) … It’s that I gage my chance of answering questions by the information provided. If I don’t feel there is enough information. I really don’t want to put people through my speculation. I do have a very wild imagination