Code:
script.Parent.Derif.OnServerEvent:Connect(function(Player)
local tweening = game:GetService("TweenService")
local Tween = TweenInfo.new(
7,
Enum.EasingStyle.Linear,
Enum.EasingDirection.Out,
0,
false,
1)
local partprop = {
Size = Vector3.new(200,200,200);
Transparency = 1
}
local plr = Player.Character or Player.CharacterAdded:wait()
local hum = plr.Humanoid
local Folder = Instance.new("Folder", plr)
local explosion = Instance.new("Part", Folder)
local anim = tweening:Create(explosion,Tween,partprop)
explosion.Transparency = 0
explosion.CanCollide = false
explosion.Anchored = true
explosion.BrickColor = BrickColor.new("Gold")
explosion.CFrame = plr.HumanoidRootPart.CFrame
explosion.Shape = Enum.PartType.Ball
explosion.Size = Vector3.new(0.1,0.1,0.1)
explosion.BackSurface = "Smooth"
explosion.FrontSurface = "Smooth"
explosion.RightSurface = "Smooth"
explosion.LeftSurface = "Smooth"
explosion.TopSurface = "Smooth"
explosion.BottomSurface = "Smooth"
explosion.Parent = Folder
anim:Play()
hum.WalkSpeed = 0
wait(10)
hum.WalkSpeed = 16
explosion.Touched:Connect(function(hit)
local inhum = hit.Parent.Humanoid
if inhum == nil then return end
if inhum.Parent == plr then
--inhum.Health = inhum.Health - 0
inhum.Health = inhum.Health - 10000
else
inhum.Health = inhum.Health - 10000
end
end)
wait(3)
Folder:Destroy()
end)
In the code above, I tried to make the Player unable to walk for 10 seconds, but because I used wait() the whole script waited. And because of this, the explosion wouldn't kill the player immediately after touching it. How do I fix this?

2 comments
put the Touched function above the wait
Indent your code