I'm trying to make a fireball spell. Everything works except the body velocity. The fireball just falls. It's unanchored and un-collided.
Local Script
local UIS = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local mouse = player:GetMouse()
local debounce = false
UIS.InputBegan:Connect(function(Input, IsTyping)
if not IsTyping then
if not debounce then
debounce = true
if Input.KeyCode == Enum.KeyCode.Z then
game.ReplicatedStorage.Fireball:FireServer(mouse.Hit.Position)
end
wait(0.1)
debounce = false
end
end
end)
Server Script
local fireball = game.ServerStorage:WaitForChild("Fireball")
game.ReplicatedStorage.Fireball.OnServerEvent:Connect(function(player, mousePos)
local character = player.Character
local newFireball = fireball:Clone()
newFireball.Position = character.HumanoidRootPart.Position
newFireball.Parent = workspace
local velocity = Instance.new("BodyVelocity", newFireball)
print(newFireball.Position)
velocity.Velocity = CFrame.new(newFireball.Position, mousePos).LookVector * 250
end)
