Hi everyone so I have an issue with this function that I made.
What it does is creates an explosion after someone activated a tool and a part touches something.
This works perfectly however there’s two things I’m having trouble to add.
I want to make it so that the ragdoll is delayed for 5 seconds (meaning the player can’t get up or move until after 5 seconds),
as well as, make it so that the player who used the tool does not get affected by the explosion at all, it just ignored the player and only flings those around him/her.
What i’ve tried:
I tried firing a remote event to disable the local players controller completely but I couldn’t do it properly.
I tried passing in the ancestor of the explosion hit but the if statements didnt work.
Any help is appreciated, thank you.
local function createExplosion(tntClone)
local e = Instance.new("Explosion")
e.BlastRadius = 22
e.DestroyJointRadiusPercent = 0
e.Position = tntClone.Position
e.Hit:Connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
local char = player.Character
local humanoid = char:FindFirstChild("Humanoid")
local HRP = char:FindFirstChild("HumanoidRootPart")
local func = coroutine.create(function()
humanoid.Sit = true
-- for 5 seconds i want to disable all of their movement
end)
coroutine.resume(func)
local BodyVelocity = Instance.new("BodyVelocity", HRP)
BodyVelocity.Velocity = Vector3.new(0,200,0)
wait(1)
BodyVelocity:Destroy()
end
end)
e.Parent = game.Workspace
game.Workspace.sounds.RocketExplosion:Play()
tntClone.Anchored = true
end