As said on the title, my script works if it was on the workspace before I run the game or even if I put there during the game but with my script this simply doesn’t work.
(obs: the script is inside a parte and it’s disabled but after I clone the part i also enable)
here’s the attack script:
local attack = script.Parent
local hitbox = attack.Hit
local cooldown = .5
local hits = {}
while attack.Parent == workspace do
task.wait()
local tparts = workspace:GetPartsInPart(hitbox)
for _, part in ipairs(tparts) do
if part.Parent then
local humanoid = part.Parent:FindFirstChild("Humanoid")
if humanoid and table.find(hits, part.Parent.Name) == nil then
local parts = part
print(parts)
local char = humanoid.Parent
print(part)
if table.find(hits, char.Name) ~= nil then
print("Bro You're cooldowned (?)")
return
elseif table.find(hits, char.Name) == nil then
print("kekeke")
table.insert(hits, char.Name)
table.clear(tparts)
hitbox.CFrame = attack.CFrame
humanoid:TakeDamage(5)
local att1 = Instance.new("Attachment")
att1.Parent = humanoid.Parent:FindFirstChild("HumanoidRootPart")
local ap = Instance.new("AlignPosition")
ap.Parent = humanoid.Parent:FindFirstChild("HumanoidRootPart")
ap.Attachment1 = attack.Mid
ap.Attachment0 = att1
ap.MaxForce = 5000
ap.MaxVelocity = 1
local currentwalkspeed = humanoid.WalkSpeed
local cJump = humanoid.JumpHeight
humanoid.WalkSpeed = 7
humanoid.JumpHeight = 3
task.wait(cooldown)
humanoid.WalkSpeed = currentwalkspeed
humanoid.JumpHeight = cJump
att1:Destroy()
ap:Destroy()
hits[table.find(hits, char.Name)] = nil
print("attack ready")
end
end
end
end
end
the server’s side remote event:
local remote = game:GetService("ReplicatedStorage").GravityAttaq1.FIRE
remote.OnServerEvent:Connect(function(p,position,time)
local ga1 = game:GetService("ReplicatedStorage").GravityAttaq1:Clone()
print(p)
print(position)
ga1.Parent = workspace
ga1.Dmg.Enabled = true
ga1.Position = position
ga1.Ball.ParticleEmitter:Emit(1)
local x = 1
task.spawn(function()
while x == 1 do
ga1.Lines.ParticleEmitter:Emit(1)
ga1.Mid.ParticleEmitter:Emit(4)
task.wait(math.random(0.25,.75)) end end)
task.wait(time*100)
x = 0
ga1:Destroy()
end)
also the script only works on one person for time, anyone know why?