im creating this “bomb” ranged attack, and everything was going smoothly untill i got to the damaging part.
The script does way too much damage. Its originally suppose to do 20 damage but instead it just kills the dummy entirely
Heres the code
Code
local event = game.ReplicatedStorage.Events.BEvents:WaitForChild("Move 1")
local pellet = game.Lighting["Game Assets"]:WaitForChild("Bravery Assets").Pellet
local TS = game:GetService("TweenService")
local bool = false
event.OnServerEvent:Connect(function(plr, mousePos, mouseTar)
if bool == false then
bool = true
print(mouseTar.Name)
-------------------------
local char = plr.Character or plr.CharacterAdded:Wait()
local rootPart = char:WaitForChild("HumanoidRootPart")
local pos = rootPart.Position
local magnitude = (pos - mousePos).Magnitude
local clone = pellet:Clone()
-------------------------
if magnitude >= 100 then return end
-------------------------
print(magnitude)
-------------------------
-------------------------------------------
--Tweening
local goal = {}
goal.Transparency = 0
local TransparemtTween = TS:Create(clone, TweenInfo.new(1),goal)
local BoomGoal = {}
BoomGoal.Size = Vector3.new(25.189, 25.189, 25.189)
BoomGoal.Transparency = 1
local boomTween = TS:Create(clone, TweenInfo.new(.2), BoomGoal)
-------------------------------------------
clone.Parent = game.Workspace
clone.Position = mousePos + Vector3.new(0,3,0)
TransparemtTween:Play()
TransparemtTween.Completed:Wait()
-------------------------------------------
--Coloring
clone.Color = Color3.new(1, 0.74902, 0.117647)
wait(.2)
clone.Color = Color3.new(1, 1, 1)
wait(.1)
clone.Color = Color3.new(1, 0.74902, 0.117647)
wait(.2)
clone.Color = Color3.new(1, 1, 1)
wait(.2)
clone.Color = Color3.new(1, 0.74902, 0.117647)
-------------------------------------------
clone.Touched:Connect(function(hit)
local CD = false
if CD == false then
CD = true
if hit.Parent.Name == plr.Name then return end
if not hit.Parent:IsA("Model") and hit.Parent:WaitForChild("Humanoid") then return end
local hitHum = hit.Parent:WaitForChild("Humanoid")
local cooldown = false
if hit.Parent:IsA("Model") and hit.Parent:WaitForChild("Humanoid") then
if cooldown == false then
cooldown = true
hitHum:TakeDamage(10)
wait(10)
cooldown = false
end
end
wait(5)
CD = false
end
end)
-------------------------------------------
wait(.2)
boomTween:Play()
boomTween.Completed:Wait()
clone:Destroy()
wait(5)
bool = false
end
end)
Help and feedback is appreciated. Thank you for your time
EDIT: Wrong Video, B,JHBHJBJH
EDIT 2: Got the right video. Sorry about that