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

6 comments
no, it still doesn't work. Does it have to do with the fact that it is a local script under StartPlayerScripts?
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
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.
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
Yes, HRP is a child of Character so do local HRP = Character:WaitForChild("HumanoidRootPart")
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.