Normal Mouse Look With a ClickDetector

…yeah, I wouldn’t do that. What I would do instead is use the UnitRay of a TouchTap via UserInputService, extend that towards the radio and go from there. Remove the ClickDetector entirely and work around it.

@REALTimothy0812 You can but that’s bad practice. I’m not sure that even works. Mobile doesn’t have mouse inputs. You’re supposed to construct a ray from TouchTap functions under UserInputService.

1 Like

You could have the billboard gui have a textbutton; And use that to detech touch. I’m not sure what you want; The question you asked was answered. You can also set PlayerMouse.Icon to set the mouse icon.

I was just suggesting multiple approaches; The mouse object works on mobile. I get that this is bad practice, which is why I also added the input service method.

every mouse icon i set for the detector gets reset in game, even after i publish and go into a new server and i already tried making the billboard gui have a textbutton, it didnt really work

So to clarify; You want a mouse icon to change when a user hovers over the e button?

i want it to stay the same as if there was no click detector

You might have better luck using a different input method then click detectors; But if you must, use the following code in local script. Note you will have to upload a copy of the roblox mouse.

ClickDetector.CursorIcon = --Mouse rbxassetid
2 Likes

@REALTimothy0812 Even if you are suggesting alternate methods, it’d be better to suggest things that actually work and don’t rely on weird behaviours to work.

Like I said, I would get rid of the ClickDetector entirely and create a full Lua implement of the detection. The first thing you want to do is check the player’s distance from the radio part and then work from there. Distance probably wouldn’t hold up on mobile so you’ll have to form that a different way.

local Camera = workspace.CurrentCamera

UserInputService.TouchTapInWorld:Connect(touchPosition, touchedUI)
    if not touchedUI then
        local unitRay = Camera:ViewportPointToRay(touchPosition.x, touchPosition.Y, 0)
        -- Replace MAX_DISTANCE with magnitude maximum you use for PC input
        local rayExtend = Ray.new(unitRay.Origin, unitRay.Direction * MAX_DISTANCE)
        -- Replace RADIO with a variable that points to the radio model
        local partCheck = workspace:FindPartOnRayWithWhitelist(rayExtend, RADIO)

        -- Replace the long variable with a distance check from partCheck
        if partCheck and PLAYER_DISTANCE_FROM_PARTCHECK <= MAX_DISTANCE then
            -- Enable the radio Gui
        end
    end
end)

You can use the same idea with Mouse input if you’re keen on making the radio work when the user clicks the radio. This way, you can have a click functionality as well without ClickDetectors. Just switch a few things around and you’re alright.

UserInputService.InputBegan:Connect(InputObject, GameProcessedEvent)
    if not GameProcessedEvent then
        local position = InputObject.Position
        local unitRay = Camera:ViewportPointToRay(position.x, position.y, 0)
        -- So on
    end
end)
1 Like

i got it working! thank you guys for helping! thank you for your time!

Click detectors or not “Weird behaviors”. They were made full the sole purpose of detecting clicks and presses.

While you may prefer to implement a lua solution (why in I also perfer), others may prefer to use a special instance made for their adaptation.

Yes, I agree the lua solutions are generally more stable as they don’t rely on other things to work. However, click detectors were made for this use case and just because they are not using the most up to data technologies does not make them “Weird Behaviors”.

In summary, everyone has their preference. Click detectors are not depreciated and are still a working and valid solution for detecting clicks. They are not “Weird Behaviors”

1 Like

I wasn’t talking about ClickDetectors? I was talking about using Mouse.Target on mobile which is awful practice and isn’t necessarily supported. It’s a mouse object representing a mouse. Mobile does not have a mouse to work with. Using the mouse object for mobile is a terrible idea.

2 Likes

Oh, I thought you were talking about removing click detectors.

“I would get rid of the ClickDetector”

I’m sorry for the misunderstanding. I get what you mean about not using the PlayerMouse for mobile, as it is a hacky behavior. I was just trying to make several suggestions, and have since removed the section.

I hope you have a good day. Sorry for the misunderstanding, I get what you meant now.