Help with "Aiming at Mouse" Scripting

Hey! I currently need some help with an undertale-related script that lets you spawn blasters that aim at the players mouse, but somehow the blasters can’t rotate at the mouses current position, help!
Heres some sample of the two scripts.

wait(0.1)
local uis = game:GetService("UserInputService")
local pl = game.Players.LocalPlayer
local mouse = pl:GetMouse()
local char = pl.Character
script.Asset.Initialize:FireServer(char)
uis.InputBegan:connect(function(input,gpe)
if not gpe then
if input.KeyCode == Enum.KeyCode.E then
script.Attack:FireServer(1,mouse.Hit)
end
end
end)```

``` lua
script.Parent.Attack.OnServerEvent:Connect(function(plr, mode, mouseHit)
if mode == 1 and coolingdown == false then
local flame = plr.Character:FindFirstChild("HandFlame")
flame.Flame.Enabled = true
coolingdown = true
local gbc = game.ReplicatedStorage:WaitForChild("Gaster Blaster"):Clone()
gbc.Parent = game.Workspace
gbc.Summon:Play()
gbc.BodyGyro.CFrame = CFrame.new(plr.Character.HumanoidRootPart.Orientation, Vector3.new(0, mouseHit.Position.Y-90, 0))
gbc.BodyPosition.Position = Vector3.new(plr.Character.Head.Position.X,plr.Character.Head.Position.Y+5,plr.Character.Head.Position.Z)
local anim = plr.Character.Humanoid:LoadAnimation(script.Parent.Asset.Anims.Send)
anim:Play()
wait(1)
flame.Flame:Emit(90)
gbc.Fire:Play()
flame.Flame.Enabled = false
coolingdown = false
end
end)

Heres a video showing the problem as well.

1 Like

Personally, being the client has control over themselves anyways, I’d handle the rotation of the player on the client-side itself.

Problem is, that you set only CFrame, but not its speed.

this is saying, rotate it to look on 0,mouse target y -90,0 and i am not shure, if you need this, i think, the bullet must go to mousehit

What do you mean by that? Please elaborate on this please, I’m new on scripting like this.

You need, to set projectiles speed, now you only set its position.