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

Cannot click an object in the character model. What should be done?

Asked by 5 years ago
Edited 5 years ago

I have a folder within my character model which has a part that has a script.

Let me illustrate this like so [Imagine this as if it is the explorer]

|_Character

|>|_Folder

|>|>|_Part

|>|>|>|_ClickDetector

|>|>|>|_Script

Problem here is that the players cannot click on anything that is inside their character model. How can I remedy this?

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago
game:GetService("Players").PlayerAdded:Connect(function(plr)
    plr.CharacterAdded:Connect(function(char)
        for _, v in pairs(char:GetChildren()) do
            if v:IsA"BasePart" then
                local cd = Instance.new("ClickDetector")
                cd.Parent = game.Workspace
                script.ClickDetectorCode:Clone().Parent = cd
                cd["ClickDetectorCode"].Disabled = false --make sure it’s Disabled is set to true! 
            end
        end
    end)

end)

script.Parent.MouseClick:Connect(function(plr)
    -- onClick code goes here 
end)
Ad

Answer this question