Remote not firing from modulescript

Hello, I am trying to fire a remote from a module script to a serverscript, to then fire another one to pick it up in a local script. But the trouble is either that it won’t fire or the server won’t pick it up. This is for a moveset just in case that is relevant. Also the “guiTween” function gets called inside of a function from a pickup of UIS fired from the localscript.

Here are the scripts:

local cooldownsRemote = script.Parent:WaitForChild("Cooldown"):WaitForChild("CooldownsRemote")

function guiTween(gui, length)
	cooldownsRemote:FireServer()

	local red = gui.Cooldown
	red.Size = UDim2.new(1,0,1,0)
	red.Transparency = 0.6
	local tween = ts:Create(red, TweenInfo.new(length, Enum.EasingStyle.Linear), {Size = UDim2.new(1,0,0,0)})
	tween:Play()
	tween.Completed:Wait()
	red.Transparency = 1

	local white = gui
	white.BackgroundColor3 = finishColour
	local tween = ts:Create(white, TweenInfo.new(0.5, Enum.EasingStyle.Linear), {BackgroundColor3 = OGColour})
	tween:Play()
end

function elemental.One(gui, length)
	print("One")
	
	wait(1)

	guiTween(gui, length)
end

The part after the cooldowns remote is not relevant it is just tweening of a gui.
This is the setup of the module:

image

The gui still gets tweened but it doesnt print “got” from this script, and acts as if it just skipped that line:

script:WaitForChild("CooldownsRemote").OnServerEvent:Connect(function(player)
	print("got")
	player.Character.Moves.Cooldowns:FireClient()
end)

And this is the final part on the local script:

local cooldownsRemote = script.Parent.Cooldowns

cooldownsRemote.OnClientEvent:Connect(function()
	print("got")
	wait(dbtimes.db1MoveTime)
	dbs.db1Move = false
end)

image

If anyone can help me I would be very grateful, thank you!

Ok, so there is a few things here, but remember whenever you fireclient and not fire to ALL clients, you will always need to pass a player object into it.

Just because you have it latched to a player, does not implicitly make calling that event going to hit that player. Now if you had it set to FireALLclients, then yes all players would hear it.

That’s likely where your major hang up is, I have provided you a link to the documentation for it as well

I’ve just recognised that as an issue and thanks for pointing it out, but the server is still not picking up the remote fired from the modulescript, am I doing something else wrong?

The module was called from a local script if that helps in any way

I’ve found a solution, for some reason my serverscript was on a RunContext called “Legacy” (I have no idea what any of those are) and I changed it to server and now it works. Thanks also to CraneStyle for pointing out my error.

1 Like

Read more about it here:
[Live] Script RunContext - Updates / Announcements - Developer Forum | Roblox
RunContext | Documentation - Roblox Creator Hub

1 Like

I suggest you try to keep as many of your scrips in these locations if possible.

  • ReplicatedFirst ← treat this as Client only
  • Replicated ← accessible server and client
  • ServerScriptService <— Server only.

– Organize and lean more to make modules then scripts if possible, and again try to minimize putting scripts on the player or ephemeral objects where you will have lots of instances of them possibly.

I know the standard practice is to put it in the playerScript area on the player but I would avoid it, I find it messy personally but that’s preference. Also it makes their contexts very very clear and cut.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.