So im making this fireball script and it has a ton of problems
-
Goes super fast if u spam
-
Messy code and hard to read
-
Doesn’t work when one of the bullets get destroyed (FIXED)
-
Just looks really wonky
Heres the code do not read if you are allergic to bad code
--Server
local Tool = game.StarterPack:WaitForChild("B a l l")
local Handle = Tool:WaitForChild("Handle")
local Yeet = game.ReplicatedStorage.Fireball:WaitForChild("Yeet")
local Players = game:GetService("Players")
local Bullet = game.ReplicatedStorage.Fireball:WaitForChild("Bullet")
local debounce = true
local count = 100
function shoot(root,name)
--parent
Bullet.Parent = workspace
--positioning
Bullet.Orientation = root.Character.HumanoidRootPart.Orientation
Bullet.CFrame = root.Character.HumanoidRootPart.CFrame
--offset so u dont die
Bullet.CFrame = Bullet.CFrame + Bullet.CFrame.LookVector * 10
-- properties
Bullet.Anchored = false
--move
while count > 1 do
Bullet.CFrame = Bullet.CFrame + Bullet.CFrame.LookVector
wait(0.1)
end
count = 100
Bullet:Destroy()
end
function damage(part)
if part.Parent.Humanoid then
wait(0.1)
part.Parent.Humanoid.Health -= 10
part.Parent.Humanoid.Jump = true
part.Parent.Humanoid.Sit = true
Bullet:Destroy()
Handle.Parent = Tool
end
end
--connect
Bullet.Touched:Connect(damage)
Yeet.OnServerEvent:Connect(shoot)
--Client
local Handle = script.Parent:WaitForChild("Handle")
local Tool = script.Parent
local Yeet = game.ReplicatedStorage.Fireball:WaitForChild("Yeet")
local Players = game:GetService("Players")
Tool.Activated:Connect(function()
print("clicked")
Yeet:FireServer(Players.LocalPlayer.Character,Players.LocalPlayer.Name)
end)
while wait() do
Handle.Fire.Size = math.random (2.5,7.5)
end
Sorry for burning ur eyes