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 5 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:

01game.ReplicatedStorage:WaitForChild("Shoot").OnServerEvent:Connect(function(plr,mouse)
02    print("FIRE")
03    local tool = plr.Character.Pew
04    local cords = tool.Handle.Position
05    local bullet = Instance.new("Part")
06    bullet.Material = Enum.Material.Neon
07    bullet.BrickColor = BrickColor.new("Dark blue")
08    bullet.Anchored = true
09    bullet.CanCollide = false
10    bullet.Size = Vector3.new(4, 0.71, 0.76)
11    bullet.Parent = tool.Handle
12    bullet.CFrame = tool.Handle.CFrame + Vector3.new(0,0,0)
13    bullet.CFrame = CFrame.new(bullet.CFrame.p, mouse.Hit.p)
14end)

here is my code for the local script:

1local RS = game:GetService("ReplicatedStorage")
2local mouse = game.Players.LocalPlayer:GetMouse()
3local player = game:GetService("Players").LocalPlayer
4local mouse = player:GetMouse()
5 
6script.Parent.Activated:Connect(function()
7    local plr = script.Parent.Handle
8    RS.Shoot:FireServer(plr,mouse)
9end)

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

Answer this question