im trying to make a fireball item, however, when i fire it, the fireball part its self stays still while the fireball moves. the object is unanchored and can collide is off
clonedFireball.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild(“Humanoid”) and not hit:IsDescendantOf(player.Character) then
if not player then
hit.Parent.Humanoid:TakeDamage(40)
clonedFireball:Destroy()
end
elseif not hit.Parent:FindFirstChild(“Humanoid”) then
local Explosion = Instance.new(“Explosion”)
Explosion.Parent = workspace
Explosion.ExplosionType = Enum.ExplosionType.NoCraters
Explosion.BlastRadius = 3
Explosion.DestroyJointRadiusPercent = 0
Explosion.Position = clonedFireball.Position
clonedFireball:Destroy()
end
end)
end)
game.ReplicatedStorage.FireballEvent.OnServerEvent:Connect(function(player)
local clonedFireball = game.ReplicatedStorage.Fireball:Clone()
local CF = player.Character.HumanoidRootPart.CFrame * CFrame.new(0, 0.5, -4)
clonedFireball.Parent = workspace
clonedFireball.CFrame = CF
local BodyVelocity = Instance.new("BodyVelocity")
BodyVelocity.Parent = clonedFireball
BodyVelocity.Velocity = player.Character.HumanoidRootPart.CFrame.lookVector * 100
-- Anchor the fireball's visual part to its BodyVelocity
clonedFireball.Anchored = true
BodyVelocity.MaxForce = Vector3.new(math.huge, math.huge, math.huge) -- Ensure the velocity is not capped
clonedFireball.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") and not hit:IsDescendantOf(player.Character) then
if not player then
hit.Parent.Humanoid:TakeDamage(40)
clonedFireball:Destroy()
end
elseif not hit.Parent:FindFirstChild("Humanoid") then
local Explosion = Instance.new("Explosion")
Explosion.Parent = workspace
Explosion.ExplosionType = Enum.ExplosionType.NoCraters
Explosion.BlastRadius = 3
Explosion.DestroyJointRadiusPercent = 0
Explosion.Position = clonedFireball.Position
clonedFireball:Destroy()
end
end)
end)
local player = game.Players.LocalPlayer
local Fireball = player:WaitForChild(“Backpack”).Fireball
local BallEvent = game.ReplicatedStorage.FireballEvent
local Debounce = false
local Cooldown = 0.5 – Change number to change cooldown
local mouse = player:GetMouse()
local inputservice = game:GetService(“UserInputService”)
inputservice.InputBegan:Connect(function(input, gpe)
if input.KeyCode == Enum.KeyCode.E and not gpe then
if player.Character:FindFirstChild(“Fireball”) and player.Character[“Fireball”]:IsA(“Tool”) then
if Debounce == false then
Debounce = true
BallEvent:FireServer(mouse.Hit.p)
wait(Cooldown)
Debounce = false
end
end
end