My script only damages one person (as you can see above), ive been trying to fix this for a while but i cant seem to find out. Can anybody help? Heres the script:
tool.UserInputT.OnServerEvent:Connect(function(player)
if db == false then
db = true
local smoke = game.ServerStorage.Projectiles.PoisenSmoke:Clone()
smoke.Parent = workspace
smoke.Position = player.Character.HumanoidRootPart.Position + Vector3.new(0,10,0)
smoke.Transparency = 1
smoke.Name = player.Name.." Poison Smoke"
local Info = TweenInfo.new(
2, -- time it takes
Enum.EasingStyle.Sine, -- easing style
Enum.EasingDirection.InOut, -- easing direction
0, -- repeats
false, -- if it should reverse back
0 -- delay time
)
local Goals = {
Transparency = 0.65-- your goals here / what it should do
}
local Tween = TweenService:Create(smoke, Info, Goals)
Tween:Play()
local isDamaging = false
local isDamaged = {}
local debounce = false
local debounce2 = false
local canDamage = false
local DOT = 5
local function Damage(hit)
if canDamage then
hit.Parent.Humanoid.JumpPower = 0
hit.Parent.Humanoid.WalkSpeed = 15
hit.Parent.Humanoid:TakeDamage(DOT)
wait(1)
debounce = false
return Damage(hit)
else
hit.Parent.Humanoid.JumpPower = 75
hit.Parent.Humanoid.WalkSpeed = 50
end
end
smoke.Touched:Connect(function(hit)
if debounce == false then
if hit.Parent:FindFirstChild("Humanoid") then
if hit.Parent ~= player.Character then
if not table.find(isDamaged, hit.Parent) then
table.insert(isDamaged,hit.Parent)
debounce = true
isDamaging = true
canDamage = true
Damage(hit)
end
end
end
end
end)
local function touchended(hit)
debounce2 = true
isDamaging = false
canDamage = false
hit.Parent.Humanoid.JumpPower = 75
hit.Parent.Humanoid.WalkSpeed = 50
table.remove(isDamaged, table.find(isDamaged, hit.Parent))
end
smoke.TouchEnded:Connect(function(hit)
if table.find(isDamaged, hit.Parent) then
touchended(hit)
end
end)
local died = false
local tween2 = TweenService:Create(smoke, Info, {Transparency = 1})
player.Character.Humanoid.Died:Connect(function()
tween2:Play()
tween2.Completed:Connect(function()
canDamage = false
smoke:Destroy()
end)
died = true
end)
game.Players.PlayerRemoving:Connect(function(removed)
if removed == player then
tween2:Play()
tween2.Completed:Connect(function()
canDamage = false
smoke:Destroy()
end)
died = true
end
end)
spawn(function()
wait(10)
tween2:Play()
tween2.Completed:Connect(function()
if not died then
canDamage = false
smoke:Destroy()
end
game.ReplicatedStorage.VenomshankCooldownActivation.T:FireClient(player, cooldownT)
wait(cooldownT)
db = false
end)
end)
end
end)