Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I make an attack at a player's hand position and face at the mouse?

Asked by
lilzy7 68
3 years ago
Edited 3 years ago

So, I have a local event for the mouse, a server script for the positioning and a remote event for communication and information.

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
            event:FireServer(MousePosition)
end)

Server Script:

local rp = game:GetService("ReplicatedStorage")
local event = rp:WaitForChild("RemoteEvent")

event.OnServerEvent:Connect(function(player,mp)
    local beam = player.Character:FindFirstChild("beam")
    beam.PrimaryPart = waterb.Cylinder
    beam.Cylinder.CFrame = CFrame.new(beam.Cylinder.Position, mp.Position)
end)

So I have a laser beam attack model located inside the player's model, so thats why it says player.Character:FindFirstChild("beam"). I sometimes get errors on line 7 about Vector 3 and CFrame but when I don't, the beam just stays still straight up, not facing the mouse position. I also tried mp instead of mp.Position, or tried changing MousePosition in local script to Mouse.Hit.p or Mouse.Hit.Position, but i just don't know what to do. Please help on how my attack can atleast face toward the mouse, or make it so the beam stays at the players hand and direction is controlled by mouse. please help!!!

1 answer

Log in to vote
0
Answered by
lilzy7 68
3 years ago

I FOUND THE PROBLEM - MY ATTACK HAD MODELS WHICH WASNT MOVING OR FACING ANYTHING BUT THE CYLINDER WAS, AND THE CYLINDER WAS INVISIBLE. BUT, SOME OTHER PROBLEMS IS THAT THE CYLINDER BARELY TILTS TO THE MOUSE AND OTHER PARTS IN THE MODEL DONT MOVE WITH THE CENTER PIECE EVEN THOUGH THE CYLINDER WAS THE PRIMARY PART

Ad

Answer this question