local userinput = game:GetService("UserInputService")
local weapons = require(game:GetService("ReplicatedStorage").WeaponsModule)
weapononcd = false
userinput.InputBegan:Connect(function(input, processed)
if input and not processed then
if input.KeyCode == Enum.KeyCode.Q then
if weapons.Sword.cooldown then
if weapononcd == false then
weapononcd = true
game.ReplicatedStorage.WeaponEvent:FireServer("Sword")
task.wait(weapons.Sword.cooldown)
weapononcd = false
end
end
end
end
end)
help (it passes the function from the modulescript into the server script where it tries to fire the function, the modulescript function should be printing on the server but it prints locally)
Oh im not trying to pass function from server to client, I get a function from the module script table which is the code for my weapon into a local script from which i send it to the server script so it can get fired server sided if you understand me, but it activates locally and not server sided. and i want it to be server sided
I understand, however in your code example you are passing a function into :FireServer() within your local script:
-- .usage here is a function, which cannot be passed
game.ReplicatedStorage.WeaponEvent:FireServer(weapons.Sword.usage)
You should instead pass the index. Since the index is a string it can be passed to the server, where the server can use that index to look up the weapon data within the same module.
wait, ima edit that sorry for wasting your time, it was the index before, not the actual function. i was trying multiple options to fix my problem and forgot to change that before posting on forum. though the server script seems to keep printing locally. its probably firing the function inside of the module script and thats not what i want, idk why it does that
Iâm quite uncertain about what youâre asking for here. I copied your code and it all appears to work just fine. The server prints âactivatedâ and follows the cooldown. What is the issue youâre facing?