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

How i make clickable player characters?

Asked by 4 years ago

Hello, so 4 hours later when i made this post i made a question for how to fix my clickable character. (https://scriptinghelpers.org/questions/91321/clickdetector-in-players-character-problem)

Now i want ask how i can make it.

My method was create a Player.CharacterAdded function to clone a ready clickdetector from serverstorage and cloned it in HumanoidRootPart(Not Worked),Torso(Not Worked) and all parts of character body. No errors was shown in devconsole.

If you make a working method tell me in comments.

1 answer

Log in to vote
1
Answered by
pwx 1581 Moderation Voter
4 years ago

Instead of putting it into the HumanoidRootPart, put it in their Character. The way, they can click any part of their Character and it will still detect.

local Players = game:GetService('Players')

function onClicked(playerWhoClicked)
    -- your code here for when player clicks on it
end

function addClickDetector(Character)
    local CD = Instance.new('ClickDetector')
    CD.Parent = Character
    CD.MaxActivationDistance = 10
    CD.MouseClick:Connect(onClicked)
end


Players.PlayerAdded:Connect(function(Player)
    Player.CharacterAdded:Connect(addClickDetector)
end)
Ad

Answer this question