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

Can not aim bullet at the mouses target?

Asked by 4 years ago

I have got a local script inside a gun sending. data through a remote event and it will not aim the bullet. here its my code for the script:

game.ReplicatedStorage:WaitForChild("Shoot").OnServerEvent:Connect(function(plr,mouse)
    print("FIRE")
    local tool = plr.Character.Pew
    local cords = tool.Handle.Position
    local bullet = Instance.new("Part")
    bullet.Material = Enum.Material.Neon
    bullet.BrickColor = BrickColor.new("Dark blue")
    bullet.Anchored = true
    bullet.CanCollide = false
    bullet.Size = Vector3.new(4, 0.71, 0.76)
    bullet.Parent = tool.Handle
    bullet.CFrame = tool.Handle.CFrame + Vector3.new(0,0,0)
    bullet.CFrame = CFrame.new(bullet.CFrame.p, mouse.Hit.p)
end)

here is my code for the local script:

local RS = game:GetService("ReplicatedStorage")
local mouse = game.Players.LocalPlayer:GetMouse()
local player = game:GetService("Players").LocalPlayer
local mouse = player:GetMouse()

script.Parent.Activated:Connect(function()
    local plr = script.Parent.Handle
    RS.Shoot:FireServer(plr,mouse)
end)

why does it do this I am using something I used in the past and it worked fine?

Answer this question