So what I have is a local script, remote event, and a server script. In the local script, I check the mouses's position, and in server script make the beam face toward that mouse.
Local Script:
local rp = game:GetService("ReplicatedStorage")
local event = rp:WaitForChild("RemoteEvent")
local player = game:GetService("Players").LocalPlayer
local Mouse = player:GetMouse()
Mouse.Move:Connect(function()
local MousePosition = Mouse.Hit.p
event:FireServer(MousePosition)
end)
Server Script:
local rp = game:GetService("ReplicatedStorage")
local event = rp.RemoteEvent
event.OnServerEvent:Connect(function(player,mp)
local beam = player.Character:FindFirstChild("beam")
beam.PrimaryPart = beam.Cylinder
beam.Cylinder.CFrame = CFrame.new(beam.Cylinder.Position, mp)
end)
So, a few problems I have here is when i run the script, my beam attack's (a model with parts and a cylinder located inside the characters model) cylinder faces the mouse a little, but only tilts a little against my mouse position. It stands straight up. What I wanted to do is the cylinder to be horizontal and turn to my mouse, not tilt and straight up. Another Problem is that I set my cylinder to the primary part of the model, but the other parts does not follow the cylinders cframe(face the mouse a little). Can anyone help me solve these two problems, and make the cylinder out of my hand too? Also, sometimes the beam is laggy and doesn't follow the cursor.

2 comments
Something to do with raycasting, not sure how that works tho.
Mouse has a lookvector property, just replace
mouse.hitwithmouse.hit.lookVector. Look Vectors are the unit ray for any vector, in the direction it is facing.