Okay so the velocity does go to where the player is looking however, it still just sits there if it doesnt hit anything
Alright try this, it should theoretically work, I’ve added some prints to see any potential errors we might encounter
LocalScript
local player = game.Players.LocalPlayer
local Fireball = player:WaitForChild("Backpack").Fireball
local BallEvent = game.ReplicatedStorage.FireballEvent
local Debounce = false
local Cooldown = 0.5
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
print("Firing fireball...")
Debounce = true
BallEvent:FireServer(mouse.Hit.p)
wait(Cooldown)
Debounce = false
else
print("Fireball on cooldown.")
end
else
print("Fireball tool not found.")
end
end
end)
script Server
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local FireballEvent = ReplicatedStorage.FireballEvent
local function createFireball(player, targetPosition)
print("Creating fireball for player:", player.Name)
local clonedFireball = game.ReplicatedStorage.Fireball:Clone()
local CF = player.Character.HumanoidRootPart.CFrame * CFrame.new(0, 0.5, -4)
clonedFireball.Parent = workspace
clonedFireball.CFrame = CF
print("Fireball position set.")
local velocityDirection = (targetPosition - clonedFireball.Position).unit
local BodyVelocity = Instance.new("BodyVelocity")
BodyVelocity.Velocity = velocityDirection * 100
BodyVelocity.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
BodyVelocity.Parent = clonedFireball
print("Fireball velocity set.")
clonedFireball.Touched:Connect(function(hit)
print("Fireball touched something.")
if hit.Parent:FindFirstChild("Humanoid") and not hit:IsDescendantOf(player.Character) then
hit.Parent.Humanoid:TakeDamage(40)
clonedFireball:Destroy()
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
FireballEvent.OnServerEvent:Connect(createFireball)
are u sure ur Fireball is not anchored ??
even if i just swap it out for a standard part, it still does the same
put ur fireballscript on a tool for try
still does the same thing. this actually makes no sense
maybe i can add you to team create and see if you can find the issue
yeah i think its a good idea do that
ive got to add you quickly first so i can make you edit
the fireball work for me ahah try too
it might be a visual thing for me then
Yes, maybe restart your Roblox Studio, the code I’ve fixed indeed works well
i restarted studio and it still does it but when i go ingame it works!!
perfect! in the script, i added a maximum distance so that the fireball eventually gets destroyed to prevent it from wandering in space forever
thank you for that, it would probably help prevent lag