I am trying to make a gun script but it gives this error Workspace.Tool.Handle.Script:7: attempt to index nil with 'Hit'. How do I fix this?
here is my code
local Tool = script.Parent.Parent local handle = script.Parent
Tool.Equipped:Connect(function()
game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(Player)
local Mouse = Player:GetMouse()
local direction = (Mouse.Hit.p - handle.Position).Unit
local Ray = Ray.new(handle.Position,direction)
local Part = Instance.new("Part")
Part.Parent = workspace
Part.Anchored = true
Part.Size = Ray.Direction - Ray.Origin
Part.Size = Part.Size + Vector3.new(0.5,0.5,0.5)
end)
end)
