Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to make clickable characters?

Asked by 3 years ago

Hey, I have been trying to make a clickDetector within a player model, but it's just not working for me. Any suggestions? Here is the code. (FYI it is stored under "StarterPlayerScripts")

local character = game:GetService("Players").LocalPlayer.Character

local clickable = Instance.new("ClickDetector",character.UpperTorso) clickable.MaxActivationDistance = 12

2 answers

Log in to vote
0
Answered by 3 years ago

The Upper and Lower Torso are underneath the HumanoidRootPart. Try changing the parent of the click detector to HumanoidRootPart.

0
no, it still doesn't work. Does it have to do with the fact that it is a local script under StartPlayerScripts? PolakBaller123 0 — 3y
0
I've never seen anybody parent an instance like how you did. Instead of doing Instance.new("ClickDetector",character.HRP), try doing clickable.Parent = HRP LeedleLeeRocket 1257 — 3y
0
do I have to declare HRP as a variable? When I created the parent, HumanoidRootPart was underlined in red. here's the updated code for your convenience. PolakBaller123 0 — 3y
0
local Players = game:GetService("Players") local Player = Players.LocalPlayer local Character = Player.Character or Player.CharacterAdded:Wait() local clickable = Instance.new("ClickDetector") clickable.Parent = HumanoidRootPart PolakBaller123 0 — 3y
View all comments (2 more)
0
Yes, HRP is a child of Character so do local HRP = Character:WaitForChild("HumanoidRootPart") LeedleLeeRocket 1257 — 3y
0
Hm, strange. It's still not working. Is it maybe because it is a local script under startplayerscripts? It isn't even adding the clickdetector when I check the HumanoidRootPart part of the explorer page while in the game. PolakBaller123 0 — 3y
Ad
Log in to vote
0
Answered by 3 years ago

You can put the click detector under the model, rather than a specific part in the character. This will allow you to click any part of the character.

Answer this question