So I’m trying to make this attack for my game that’s essentially a bow and arrow, you click at a certain spot on the screen and it will shoot an arrow at where your cursor was.
The problem being though, wherever I click it just seem to shoot at a completely random direction. It is a consistent randomness though as if I keep my cursor in the same spot for multiple shots it will keep shooting in that same randomized direction.
Here is the snippet of code that spawns the arrow, I’ve cut out any unimportant code for brevity’s sake:
script.Parent.RemoteEvent.OnServerEvent:Connect(function(plr,X,Y,Z)
if active == 1 then
active = 0
local g = game.ReplicatedStorage["Dream Sans"].Arrow:Clone()
g.owner.Value = script.Parent.Parent
g.Parent = workspace
g.PrimaryPart = g.Head
g:SetPrimaryPartCFrame(script.Parent.Parent["Torso"].CFrame * CFrame.Angles(math.rad(X),math.rad(Y),math.rad(Z))) --Puts the arrow at the owner's torso then change it's direction
Tool.Enabled = false
task.wait(1)
Tool.Enabled = true
active = 1
end
end)
And yes the tool itself does have a RemoteEvent inside of it, here are the content’s of the LocalScript inside of it:
script.Parent.Parent.Equipped:Connect(function(Mouse)
Mouse.Button1Down:Connect(function()
script.Parent:FireServer(Mouse.Hit.X,Mouse.Hit.Y,Mouse.Hit.Z)
end)
end)
So far I have tried taking out the ‘math.rad’ parts inside of the direction script with essentially the same results but just with a different randomness if that makes sense. I do believe that the issue lies with the ‘XYZ’ values not actually being directions and moreso specific points at which you click at that go beyond the ideal 180 number for angle values.
Though the question is, how would I go about factoring that into the script though? Any and all help is greatly appreciated, thank you! ^ ^