So I have some code so if the player hovers on a interaction it shows it and yk does it, I want it to be proximity based though and not mouse hover here is my current code:
UserInputService.InputChanged:Connect(function(input, gpe)
if gpe then return end
if input.UserInputType == Enum.UserInputType.MouseMovement then
if mouse.Target then
if SelectedPart ~= nil and SelectedPart:FindFirstChild("Interaction") and SelectedPart ~= mouse.Target and SelectedPart ~= mouse.Target.Parent then
OperateUIElements(false)
SelectedPart = nil
return
end
if SelectedPart ~= mouse.Target then
if mouse.Target:IsA("BasePart") and mouse.Target:FindFirstChild("Interaction") and mouse.Target.Interaction.Value and player:DistanceFromCharacter(mouse.Target.Position) <= MinimumDetectionDistance then
SelectedPart = mouse.Target
OperateUIElements(true)
elseif mouse.Target.Parent:IsA("Model") and mouse.Target.Parent:FindFirstChild("Interaction") and mouse.Target.Parent.Interaction.Value and player:DistanceFromCharacter(mouse.Target.Parent:GetPivot().Position) <= MinimumDetectionDistance then
SelectedPart = mouse.Target.Parent
OperateUIElements(true)
end
end
else
if SelectedPart ~= nil then
OperateUIElements(false)
end
SelectedPart = nil
end
end
end)
Anyway I can do this?