-
What do you want to achieve? a simple fireball ability
-
What is the issue? the fireball doesn’t show properly and I take damage instead of the target
-
What solutions have you tried so far? I’m pretty new to scripting and I followed a tutorial and modified it to my liking but I think I did something wrong.
ServerScript
local fireball = game:GetService("ServerStorage").Blast
local fireballSpeed = 100
local fireballLifetime = 5
local fireballDamage = 15
local cooldown = 1.5
local canshoot = true
script.Parent.Fire.OnServerEvent:Connect(function(player)
if not canshoot then return end
canshoot = false
local root = player.Character.HumanoidRootPart
local bv = Instance.new("BodyVelocity")
bv.MaxForce = Vector3.new(1,1,1) * 30000
bv.Velocity = root.CFrame.lookVector * fireballSpeed
local fb = fireball:Clone()
fb.Parent = game.Workspace
fb.CFrame = root.CFrame
bv.Parent = fb
game.Debris:AddItem(fb,fireballLifetime)
fb.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
hit.Parent.Humanoid.Health -= fireballDamage
fb:Destroy()
end
end)
wait(cooldown)
canshoot = true
end)
any help is greatly appreciated