Thank you so much for this information, it really means alot, and I have learned a great amount from this thread. I hope this works!!
I was finally able to get it working!! Now Iām only facing one problem, my weapon has a local debounce variable and since they both run on seperate scripts I tried to compensate with a similar debounce (with the same wait values in the hopes that you donāt get stamina taken away too early or too late before you swing causing a false reg) but it still seems to happen even though I am using the same amount of wait time for the debounce. Any solutions? (I tried connnecting the weapon to a boolvalue called debounce and using that but I couldnāt get it to work, and I felt like it was a inefficient solution) Here is the script:
local staminaModule = require(game.ReplicatedStorage:WaitForChild("StaminaModule"))
local staminaRequired = staminaModule.maxStamina * .30
local db = false
script.Parent.Activated:Connect(function()
if (staminaModule.currentStamina >= staminaRequired) then
if not db then
script.Parent.Swing:FireServer()
staminaModule.ModifyStamina(staminaModule.currentStamina - staminaRequired)
db = true
wait(.6)
db = false
end
end
end)
Also I feel like sometimes my swings are kind of delayed? This is probably due to the way I wrote my weapon script, but I am using a remote event and when it is fired it swings the weapon
Maybe I should subtract the stamina using the weapon script? So it cannot be delayed? But you said it was best to handle them on the client, so should I find a different solution?
Okay I got it all working and good including the debounce, so please ignore my other comments (sorry that this is such a mess I suck at this) all except for one thing, when the player dies I get an error in output āCan only tween objects in workspaceā which then causes the gui tween to stop working. How can I fix?
Alright nevermind I figured it out, I had to disable reset on spawn. Thank you all you have done to help.