local damage = 100
local RANGE = 150
-- ONLY EDIT HERE
local debris = game:GetService("Debris")
local debounce = false
game.ReplicatedStorage.SkillEvent.OnServerEvent:Connect(function(x,plr,number)
plr.Character.HumanoidRootPart.Anchored = true
game.ReplicatedStorage.SkillEvent:FireAllClients(plr)
local pos = plr.Character.HumanoidRootPart.CFrame * CFrame.new(0,-20,-200)
local Skill1 = game.ReplicatedStorage.Skill:Clone()
Skill1:MoveTo(pos.Position)
local targetpart = Instance.new("Part",workspace)
debris:AddItem(targetpart,8)
debris:AddItem(Skill1,8)
targetpart.Anchored = true
targetpart.Transparency = 1
targetpart.Name = "target"
targetpart.CanCollide = false
script.Sound:Play()
wait(2)
local locate = 0
if debounce == false then
if number == 1 then
targetpart.CFrame = pos
local allplayers = game.Players:GetChildren()
debounce = true
coroutine.wrap(function()
for a,b in pairs(allplayers) do
Skill1.Parent = workspace
repeat
local range = (Skill1.base.Position - b.Character.HumanoidRootPart.Position).magnitude
if range < RANGE then
b.Character.HumanoidRootPart.CFrame = Skill1.base.CFrame * CFrame.new(0,-5,0)
b.Character.HumanoidRootPart.Anchored = true
b.Character.Humanoid:TakeDamage(damage)
end
locate = locate + 1
wait(.1)
until locate == 50
plr.Character.HumanoidRootPart.Anchored = false
script.Sound:Stop()
targetpart:Destroy()
Skill1.Parent = nil
wait(8)
debounce = false
end
end)()
end
end
end)
The problem: 2nd time playing code “local Skill1 = game.ReplicatedStorage.Skill:Clone()” not working