Because when I run the remote, the fireball doesn't go to the actual location of the mouse

Hi, why when I run a remote, the fireball doesn’t go to the mouse location. Here’s a video:

I want the ball to go to the MOUSE CENTER, here’s the code if you want it:

Remote Event Call

-- Services
local replicatedStorage = game:GetService("ReplicatedStorage")
local userInputService = game:GetService("UserInputService")

-- Variables
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local remoteEvent = replicatedStorage.ElementsRemoteEvents.Fire.FireballRain.FireballRainRemoteEvent
local playerMouse = player:GetMouse()

-- Settings
local debounce = true
local key = 'Q'

userInputService.InputBegan:Connect(function(input, isTyping)
	if isTyping then return end
	local keyPressed = input.KeyCode
	if keyPressed == Enum.KeyCode[key] and debounce and character then
		debounce = false
		remoteEvent:FireServer(playerMouse.Hit)
		wait(1)
		debounce = true
	end
end)

Fireball Settings

-- Services
local replicatedStorage = game:GetService("ReplicatedStorage")

-- Variables
local remoteEvent = replicatedStorage.ElementsRemoteEvents.Fire.FireballRain.FireballRainRemoteEvent

-- Settings
local damage = 10

remoteEvent.OnServerEvent:Connect(function(player, playerMouse)
	local character = player.Character or player.CharacterAdded:Wait()
	
	local fireballRainModel = Instance.new("Model")
	fireballRainModel.Parent = workspace
	
	local centralPart = Instance.new("Part")
	centralPart.Shape = Enum.PartType.Ball
	centralPart.Anchored = false
	centralPart.CanCollide = false
	centralPart.Color = Color3.fromRGB(138, 72, 39)
	centralPart.Material = Enum.Material.Neon
	centralPart.Size = Vector3.new(2, 2, 2)
	centralPart.Name = "CentralPart"
	centralPart.CFrame = character.HumanoidRootPart.CFrame
	centralPart.Parent = fireballRainModel
	
	local fieldPart = Instance.new("Part")
	fieldPart.Shape = Enum.PartType.Ball
	fieldPart.Anchored = false
	fieldPart.CanCollide = false
	fieldPart.Color = Color3.fromRGB(213, 115, 61)
	fieldPart.Material = Enum.Material.Neon
	fieldPart.Transparency = 0.3
	fieldPart.Size = Vector3.new(2.4, 2.4, 2.4)
	fieldPart.Name = "FieldPart"
	fieldPart.CFrame = character.HumanoidRootPart.CFrame
	fieldPart.Parent = fireballRainModel
	
	local fireParticles = replicatedStorage.ElementsModels.Fire.FireballRain.CentralPart.fireParticles:Clone()
	fireParticles.Parent = centralPart
	
	local bodyVelocity = Instance.new("BodyVelocity")
	bodyVelocity.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
	bodyVelocity.Velocity = playerMouse.lookVector*40
	bodyVelocity.Parent = centralPart
	
	local bodyVelocityTwo = Instance.new("BodyVelocity")
	bodyVelocityTwo.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
	bodyVelocityTwo.Velocity = playerMouse.lookVector*40
	bodyVelocityTwo.Parent = fieldPart
	
	local debounce = true
	fieldPart.Touched:Connect(function(h)
		if h.Parent:FindFirstChild("Humanoid") and h.Parent.Name ~= player.Name and debounce then
			debounce = false
			local enemy = h.Parent.Humanoid
			enemy:TakeDamage(damage)
			fireballRainModel:Destroy()
			wait(1)
			debounce = true
		end
	end)
end)

Please help me, thanks.

If this is not the correct category, please tell me what’s the correct category, thanks!

This is a script, so it belongs in #help-and-feedback:scripting-support not #help-and-feedback:building-support.

2 Likes

Okay.

TAGS: HEART BUTTON NOT WORKING

This is because it is firing 40 studs forwards from the mouse in it’s lookVector, it is firing in the direction it is told to move in.
If you just set the Velocity to the lookVector it should hopefully align:

bodyVelocity.Velocity = playerMouse.lookVector
2 Likes

It moves very slow, what can I do move it faster?

You could try this:

bodyVelocity.Velocity = (playerMouse.Position - character.HumanoidRootPart.Position).Unit * 40
1 Like

Thank you very much, it is working, THANK YOU!!