It still didn’t work. And I realised that using debounce in this module script is probably not a good idea, cuz many players may get ragdolled at the same time, and then because of debounce it will work only for one of them, right?
Yep, you’d have to store debounce for each player separately in a table i guess
Is that work when you destroy wait(3)
?
Another problem i had with modules was when i was waiting for remote functions and events. Try moving the second line in the script (local RE = game.ReplicatedStorage.Ragdoll
) to the first line of the function for example.
Doesn’t work. Also tried doing WaitForChild() for the remote event. Still nothing
My Ragdolled character is reflecting my emotional state after being baffled by this issue for 5 hours.
I’m curious, try this and see what it prints out:
print("Bef")
for i = 1,3 do
task.wait(1)
warn("WAITED " .. i .. " OUT OF 3")
end
print("Aft")
I just literally copied and pasted this into my studio and it works fine for me lol
Furthermore, I want to see if you can loop forever:
while true do
task.wait(0.1)
print("Nice!")
end
It printed what I expected it to print. Nothing. I just also discovered that body velocity inside head wasn’t destroying either. Removing the whole bodyvelocity part in the script still changed nothing
Did you also call the function from another script with touched event like I am doing?
So after printing WAITED 3 OUT OF 3
, it doesn’t print out Aft
?
Yeah, at first i tried just the module script but it worked fine so i tried the boulder script and that still worked. Might be a bug somewhere in studio itself then
Literally only difference is that my module script isn’t called Module but the content is the exact same
(Even when i renamed it back to Module, still works lol)
try this:
coroutine.wrap(function()
print("Nice!")
end)()
coroutine.wrap(function()
task.wait()
print("Nice X2!")
end)()
task.wait()
print("Very nice!")
If any of those print then we have discarded the option that maybe it is in a context that does not allow halting (wait, multi-task etc…)
I just changed boulder script to this and it worked.
local boulder = script.Parent
local M = require(game.ServerScriptService.Module)
boulder.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
boulder.CanTouch = false
M.Ragdoll(hit.Parent, true)
end
end)
Boulder was falling from a hill at high speed, so it was touching character like 16 times. The “Bef” was being printed 16 times.
So it was calling the module function ~16 times. I guess the debounce inside the module function itself didn’t work, because even tho the majority of the function wasn’t being executed, the function itself was still being called.
I guess I will have to add debounces in every script that calls the ragdoll function, which is annoying.
This is still a very weird an unsolved issue, because no matter how many times it is called or how many times “BEF” is printed, the “Aft” still should print, at least once
So if anybody has any guesses why it is not happening, do voice your guessings.
Can you test what I said? If none of them print then I am pretty sure it is a context that doesn’t allow halting which would explain why you can’t wait