I can’t get my remote event from server to client to fire. The remote event that is not firing is the Flaming one and it fires inside of another event if RNG hits the 1/5 chance. Here is the script that calls the event.
local R = game.ReplicatedStorage.HatRemotes.Cap
R.OnServerEvent:Connect(function(plr)
local RNG = math.random(1, 5)
if RNG == 5 then
print("FlamingS")
plr.leaderstats.FlamingCap.Value = plr.leaderstats.FlamingCap.Value + 1
game.ReplicatedStorage.Remotes.Flaming:FireClient(plr) -- HERE is where it is called
print("Flaming") -- Prints
else
plr.leaderstats.Cap.Value = plr.leaderstats.Cap.Value + 1
end
end)
This is the script for the event
game.ReplicatedStorage.Remotes.Flaming.OnClientEvent:Connect(function()
task.wait(1.03)
workspace.Crate.Inside.Fire.Enabled = true
task.wait(3.06)
workspace.Crate.Inside.Fire.Enabled = false
print("DoneF") -- Doesn't print or error out
end)
Can you please put another print() before the task.wait()'s in the second script
Is the second script in a local script or a server script?
1 Like
Local script, should it be server sided?
No, but the first script should be
Can you please put print() before the task.wait()'s in the second script
1 Like
It didn’t print before the wait either.
Where is the LocalScript
located in the game? If it’s not a descendant of one of the following objects (listed at the bottom of this post), its code will not run which means that the client would never actually be listening for the RemoteEvent to be called.
- A Player’s
Backpack
, such as a child of a Tool
- A Player’s
Character
model
- A Player’s
PlayerGui
- A Player’s
PlayerScripts
.
- The
ReplicatedFirst
service
2 Likes
You’re right, I forgot that you can’t put client sided things in ServerScriptService but It is now in ReplicatedFirst and it says that “Remotes is not a valid member of ReplicatedStorage”
1 Like
Instances in the ReplicatedFirst
Service become “visible” to the client before anything in the other Services (according to its Developer Hub Documentation) which means that the “Remotes” folder that is being referenced in the ReplicatedStorage
may not have been replicated to the client yet. In other words, the LocalScript’s code likely ran before it was able to know that the folder was there yet.
Adding :WaitForChild()
on the folder and the subsequent RemoteEvents that are referenced may resolve that error.
2 Likes
It works in PlayerScripts actually, Thank you for helping guys!
2 Likes