So I made a script where if I press a key, it then spawns a part on my character. Anyone caught within that part gets damaged. I made it so that when doing this, the player won’t be able to move and at the end of it their normal speed returns. But the character isn’t able to move at all
This is my script
re.OnServerEvent:Connect(function(Player)
local character = workspace:WaitForChild(Player.Name)
local humanoid = character:WaitForChild("Humanoid")
humanoid.WalkSpeed = 0
humanoid.JumpPower = 0
local HaoHaki = game:GetService("ReplicatedStorage"):WaitForChild("HaoHaki")
HaoHaki:Clone()
HaoHaki.Parent = workspace
HaoHaki.CFrame = character.HumanoidRootPart.CFrame
game.Debris:AddItem(HaoHaki, 2)
local HaoTween = game:GetService("TweenService"):Create(HaoHaki, TweenInfo.new(2, Enum.EasingStyle.Linear,Enum.EasingDirection.Out, 0, false), {Transparency = 1, Size = Vector3.new(100,100,100)})
HaoTween:Play()
for i, players in pairs (game:GetService("Players")) do
if players.Name ~= Player.Name then
local playersChar = workspace:WaitForChild(players.Name)
local distance = (playersChar.HumanoidRootPart.Position - character.HumanoidRootPart.Position).magnitude
if distance < 100 then
print ("Affected")
playersChar.Humanoid:TakeDamage(math.random(1, 10))
end
end
end
for i, dummies in pairs(workspace:GetChildren()) do
if dummies:IsA("Model") and dummies:FindFirstChild("Humanoid") then
dummies.Humanoid:TakeDamage (math.random(1, 10))
end
end
wait(1)
humanoid.WalkSpeed = 16
humanoid.JumpPower = 16
end)```