local down = true local player = game.Players.LocalPlayer local mouse = player:GetMouse() local we = false mouse.KeyDown:Connect(function(key) key = key:lower() if key == "v" then local e = Instance.new("Part",workspace) e.Position = mouse.Hit.Position --here is error end end)
First of all, you really should rewrite this to not use deprecated services.
However, I think your issue will be solved if you simply change mouse.Hit.Position
to mouse.Hit.p
I've rewritten this using newer services for you!
--Warning: Untested code. I'm typing this into the answer box! local UserInputService = game:GetService("UserInputService") local player = game.Players.LocalPlayer local mouse = player:GetMouse() local function onInputBegan(input, gameProcessed) if not gameProcessed and input.UserInputType == Enum.UserInputType.Keyboard then if input.KeyCode == Enum.KeyCode.V then local e = Instance.new("Part") e.Position = mouse.Hit.p e.Parent = workspace end end end UserInputService.InputBegan:Connect(onInputBegan)