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!
A solution to my problen.
What is the issue? Include screenshots / videos if possible!
If statement not checking after “and” and script sometimes not running after task.wait
local Object = script.Parent.Handle.Cube
local owner = Object:GetAttribute(“Owner”)
local db = true
local r = require(game:GetService(“ReplicatedFirst”):WaitForChild(“ModuleRagdoll”))
Object.Touched:Connect(function(BasePart)
if BasePart.Name == "HumanoidRootPart" and Object.Velocity.Magnitude > 20 and db == true then
local char = BasePart.Parent
local Torso = char:FindFirstChild("Torso")
if char.Name ~= owner and Torso:GetAttribute("Ragdolled") == true then return end
db = false
local hum = char:WaitForChild('Humanoid')
hum:TakeDamage(25)
r.RagdollCharacter(char)
task.wait(2)
r.UnRagdollCharacter(char)
end
end)
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I did but I found nothing.
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
Object.Touched:Connect(function(BasePart)
if BasePart.Parent:FindFirstChild("Humanoid") then
local character = game.Players:GetPlayerFromCharacter(BasePart.Parent)
if BasePart.Name == "HumanoidRootPart" and Object.Velocity.Magnitude > 20 then
if db then
-- do stuff
end
end
end
end)
This is because you don’t set the debounce back to ‘true’.
Updated Code:
local Object = script.Parent.Handle.Cube
local owner = Object:GetAttribute("Owner")
local db = true
local r = require(game:GetService("ReplicatedFirst"):WaitForChild("ModuleRagdoll"))
Object.Touched:Connect(function(BasePart)
if BasePart.Parent:FindFirstChild("Humanoid") and Object.Velocity.Magnitude > 20 and db == true then
local char = BasePart.Parent
local Torso = char:FindFirstChild("Torso")
if char.Name ~= owner and Torso:GetAttribute("Ragdolled") == true then return end
db = false
local hum = char:WaitForChild('Humanoid')
hum:TakeDamage(25)
r.RagdollCharacter(char)
task.wait(2)
r.UnRagdollCharacter(char)
db = true -- set debounce to true
end
end)
I forgot to tell that this object is cloned every time it’s used so it doesn’t really matter if I set it back to true, it’s basically a tool which launches this part if that makes sense