ahembo
(ahembo)
June 25, 2023, 4:48pm
1
You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? Keep it simple and clear!
I am trying to make a stun system.
What is the issue? Include screenshots / videos if possible!
Task.delay refuses to work and I have tried nearly everything to fix it
char:WaitForChild("RagdollTrigger").Value = true
task.delay(5, function()
print("sd")
char:WaitForChild("RagdollTrigger").Value = false
print("sd")
end)
Are you receiving any errors in the output logs?
1 Like
Fizzitix
(Fizzitix)
June 25, 2023, 4:51pm
3
Does “SD” print after 5 seconds? If so, the problem is most likely with your ragdoll system.
1 Like
ahembo
(ahembo)
June 25, 2023, 4:51pm
4
Not recieving any errors in the output logs
1 Like
ahembo
(ahembo)
June 25, 2023, 4:52pm
5
The “SD” doesn’t print after 5 seconds so i dont think its the problem with the ragdoll system
1 Like
What output do you get when you do this?
local RagdollTrigger = char:WaitForChild("RagdollTrigger", 10)
print(RagdollTrigger, 'was found!')
RagdollTrigger.Value = true
task.delay(5, function()
print("sd")
char:WaitForChild("RagdollTrigger").Value = false
print("sd")
end)
Edit: While testing this code, let the game run for at least 10 seconds exactly before drawing any conclusions.
1 Like
ahembo
(ahembo)
June 25, 2023, 4:56pm
7
It prints “RagdollTrigger was found!”
1 Like
Another experiment, what output do you get when you do this?
task.delay(2, function()
print("task.delay is working!")
end)
local RagdollTrigger = char:WaitForChild("RagdollTrigger", 10)
print(RagdollTrigger, 'was found!')
RagdollTrigger.Value = true
1 Like
ahembo
(ahembo)
June 25, 2023, 5:02pm
9
Only prints “RagdollTrigger was found!”
1 Like
RoBoPoJu
(RoBoPoJu)
June 25, 2023, 5:12pm
10
Where is the script located? Can you still find it in the explorer after the delay time has passed? If you can, is it still enabled?
2 Likes
ahembo
(ahembo)
June 25, 2023, 5:13pm
11
The script is a modulescript and it’s in ReplicatedStorage
1 Like
Your mistake is using delay over coroutines, delay has a wait in it which can take up to 25 seconds to complete. Try and use coroutines instead. Its recommended to avoid spawn and delay.
1 Like
ahembo
(ahembo)
June 25, 2023, 5:21pm
13
The script that was using the modulescript had to be deleted after 2 seconds so that’s why the task.delay didnt work, thanks
2 Likes
I’ve never heard this advice before, would you mind elaborating on this rule? Why is coroutine better than task.spawn? I have previously heard that it is better to use task.spawn() over spawn(). What do you mean by this?
Thank you
This is only true for the legacy version of delay. OP was using task.delay, which does not have this problem.
1 Like
system
(system)
Closed
July 9, 2023, 6:31pm
16
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.