As you can see, it clicks at a certain angle,
but when it goes beyond that angle, it doesn’t click.
This is a fatal error for my game.
What’s the problem? I’ll also show you the local script code of the tool.
local tool = script.Parent
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local handles = tool:WaitForChild("Handles")
local replicatedStorage = game:GetService("ReplicatedStorage")
local toolEvent = replicatedStorage:WaitForChild("ToolEvent")
local camera = game.Workspace.CurrentCamera
local draggingInProgress = false
handles.Parent = player.PlayerGui
local partName
local originalCameraType
local originalCameraSubject
tool.Activated:Connect(function()
local target = mouse.Target
if target and target.Locked then
return
end
if target.Parent:FindFirstChildOfClass("Humanoid") then
return
end
partName = target.Name
local playerPart = player:FindFirstChild(partName)
if playerPart == nil then
return false
end
if target.Name ~= playerPart.Name then
return false
end
handles.Adornee = target
_G.PartSelected = target
end)
handles.MouseButton1Down:Connect(function()
originalCameraType = camera.CameraType
originalCameraSubject = camera.CameraSubject
camera.CameraType = Enum.CameraType.Scriptable
local dragC, mouseUpC
local prevDist = 0
dragC = handles.MouseDrag:Connect(function(face, distance)
local deltaDist = (distance - prevDist)
local deltaDistMagnitude = math.abs(deltaDist)
local deltaDistRounded = math.sign(deltaDist) * (math.floor(deltaDistMagnitude / 0.5) * 0.5)
if deltaDistMagnitude >= 0.5 then
local resizeDir
if face == Enum.NormalId.Top then
resizeDir = Vector3.new(0, 1, 0)
elseif face == Enum.NormalId.Bottom then
resizeDir = Vector3.new(0, -1, 0)
elseif face == Enum.NormalId.Left then
resizeDir = Vector3.new(-1, 0, 0)
elseif face == Enum.NormalId.Right then
resizeDir = Vector3.new(1, 0, 0)
elseif face == Enum.NormalId.Front then
resizeDir = Vector3.new(0, 0, -1)
elseif face == Enum.NormalId.Back then
resizeDir = Vector3.new(0, 0, 1)
else
resizeDir = Vector3.new(0, 0, 0)
end
local globalResizeDir = handles.Adornee.CFrame:VectorToWorldSpace(resizeDir)
handles.Adornee.Position += globalResizeDir * deltaDistRounded
prevDist = math.sign(distance) * (math.floor(math.abs(distance) / 0.5) * 0.5)
end
end)
mouseUpC = handles.MouseButton1Up:Connect(function()
camera.CameraType = originalCameraType
camera.CameraSubject = originalCameraSubject
dragC:Disconnect()
mouseUpC:Disconnect()
toolEvent:FireServer(handles.Adornee, handles.Adornee.Position)
end)
end)
tool.Unequipped:Connect(function()
for _, v in pairs(player.PlayerGui:GetChildren()) do
if v.Name == "Handles" then
v.Adornee = nil
end
end
end)
I’m really new to this situation, so I can’t even figure out what to do. Please help me