How to fix the problem below:
- The object that is following my cursor is halfway through the objects. It has a very small collision hitbox.
- The object goes near the camera when equipped.
Here is the code relevant to this.
local RunService = game:GetService("RunService")
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local mouse = Player:GetMouse()
-- Variables
local ghostConnection
local ghost
Character.ChildAdded:Connect(function(child)
if not child:isA("Tool") then return end
if not child:FindFirstChild("ConstructPart") then return end
local tempFolder = workspace:FindFirstChild(Player.UserId .. "_TEMP")
ghost = child.Handle:Clone()
ghost.Name = "GhostObject"
ghost.Parent = tempFolder
ghostConnection = RunService.RenderStepped:Connect(function()
if mouse.move then
ghost.Orientation = Vector3.new(0, 0, 0)
ghost.Position = mouse.Hit.p
end
end)
end)
Character.ChildRemoved:Connect(function(child)
ghost:Destroy()
ghostConnection:Disconnect()
end)
Sample Video: