Help on click detector distance

Hello, so i am trying to make it so that if my custom character is close to a door and the distance is close enough to the click detector than it will be able to be clickable, but since the real character isnt close to the door than it wont work. Is there any way to fix this?

2 Likes

I am pretty sure there is a max distance property.

1 Like

I know that but im trying to make it so that the click detector thinks the custom character is the real player.

1 Like

The custom character is the real player. If you do Player.Character it makes roblox think that is your character.

1 Like

You can change the MaxActivationDistance property and set it to a certain value where a certain amount of stud(s) is where a user can click something for the ClickDetector.

local Detect = script.Parent
local DetectDistance = Detect.ClickDetector.MaxActivationDistance

Detect.ClickDetector.MouseClick:Connect(function()
	if DetectDistance == 55 then
		print("55!")
	end
end)

Insert a ClickDetector, and change a value of MaxActivationDistance in the properties tab.

2 Likes

I have a game with custom characters all you need to do is do Player.Character

1 Like

So basically i have to get the magnitude from the custom character root from the door and make it times as much as the mag? Correct me if im wrong.

Insert a click detector in the part find a setting called MaxActivationDistance and configure that. Or you can configure it in the code like this.

local ClickDetector = script.Parent
ClickDetector.MaxActivationDistance = 150

Should work even for a custom char.

Or do
workspace:FindFirstChild(Player.Name)

Ok so i looked at you’re probable-solutions and thought of making a part that follows the mouse and if the distance is close enough it gets the real characters mag from the door and uses it as max activation +1 which then can detect, this only happens if the mouse is touching the door / part. – give me your opinons on this.

All you have to do is change the character of the player.

local customChar = workspace.Character

game.Players.PlayerAdded:Connect(function(player)
    player.Character = customChar
end)

As long as the custom character is a model, anything that does player.Character = customCharacter will work

This wouldnt work because when you click the button to become you couldnt make a playeradded callback because the player is already in game, and when i tried using player.chr = custom it resets the player resulting of deleting the customchar aswell.

Try changing it as the player spawns in.