I’ve made a fireball script following a guide but after using it for a little bit it starts to freeze mid way then it’ll continue. Not too sure what to do I’ve been messing around with it but I can’t get it to fix.
Here’s the code
local rp = game:GetService("ReplicatedStorage")
local fireball = rp:WaitForChild("Fireball")
local debris = game:GetService("Debris")
local meshes = script.Parent.Parent.ServerStorage:WaitForChild("Meshes")
fireball.OnServerEvent:Connect(function(Player)
local char = Player.Character
local humanoid = char:WaitForChild("Humanoid")
local humrp = char:WaitForChild("HumanoidRootPart")
local fireballmain = meshes:WaitForChild("FireballMain"):Clone()
fireballmain.CFrame = humrp.CFrame * CFrame.new(0,0,-3)
fireballmain.Parent = workspace
local fireballout = meshes:WaitForChild("FireballOut"):Clone()
fireballout.CFrame = fireballmain.CFrame
fireballout.Parent = workspace
local weld = Instance.new("WeldConstraint")
weld.Parent = fireballmain
weld.Part0 = fireballout
weld.Part1 = fireballmain
debris:AddItem(fireballmain, 2)
debris:AddItem(fireballout, 2)
local vel = Instance.new("BodyVelocity",fireballmain)
vel.MaxForce = Vector3.new(5000,5000,5000) * 3000
vel.Velocity = humrp.CFrame.lookVector * 100
end)
local vel = Instance.new("BodyVelocity",fireballmain)
vel.MaxForce = Vector3.new(5000,5000,5000) * 3000
vel.Velocity = humrp.CFrame.lookVector * 100
To this
local vel = Instance.new("BodyVelocity")
vel.MaxForce = Vector3.new(5000,5000,5000) * 3000
vel.Velocity = humrp.CFrame.lookVector * 100
vel.Parent = fireballmain
Parenting an instance before defining/changing it’s properties is bad practice because A) its inefficient and B) can, in some cases, cause stuttering as seen above