ive been trying to make a bullet system that creates a part and stretches between the gun and the target.
however when i try to pass the mouse.hit to a normal script using a remote event it keeps returning nil
ive tried everything but it keeps returning the same, am i missing something??
Local script:
local db = true
local shooting = false
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local mouse = player:GetMouse()
print(mouse.Hit)
local remoteEvent = game.ReplicatedStorage:WaitForChild("wheninputxdxd")
local function onMouseClick()
if script.Parent["gun?"].Value == true then
print("a")
shooting = true
while shooting == true do
local mouse2 = mouse.Hit.Position
remoteEvent:FireServer(mouse2, mouse.TargetFilter, db)
wait(0.15)
end
else
print("b")
end
end
mouse.Button1Down:Connect(onMouseClick)
Script:
local remoteEvent = game.ReplicatedStorage:WaitForChild("wheninputxdxd")
local function onRemoteMouseEvent(player, hit, targetfilter, db)
local bull = makebullet()
local b = script.Parent.Model.shoot.Position
print(hit)
local a = hit
local tt = workspace:WaitForChild("bullets")
targetfilter = tt
--------------------------------------------------------------------
local Distance = (b-a).Magnitude
bull.CFrame = CFrame.new(b,a) * CFrame.new(0,0,-Distance/2)
bull.Size = Vector3.new(0.1,0.1,Distance)
game.Debris:AddItem(bull, 0.1)
end
Output:
nil - Studio ( the normal script )
19:52:33.241 Players.Osmandhirchannel.Backpack.gun.damage:48: attempt to perform arithmetic (sub) on Vector3 and nil - Studio ( normal script )
19:52:35.095 -6808.22754, -7014.63525, -2076.25317, 0.292361528, -0.671580613, 0.680811584, -0, 0.711916745, 0.702264011, -0.956307888, -0.205314979, 0.20813708 - Cliente - server:13 ( local script