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

Why doesn't this script run upon clicking a brick?

Asked by 5 years ago
Edited 5 years ago

Edited the title so it seemed less like a request.

-

Hello again, I'm attempting to apply clothing to a player when they click a brick, this is the script I have:

01function onClicked(player)
02    if player:FindFirstChild("Shirt") then
03        player:FindFirstChild("Shirt"):Destroy()
04    end
05    if player:FindFirstChild("Pants") then
06        player:FindFirstChild("Pants"):Destroy()
07    end
08          Instance.new("Shirt",player)
09          player.Clothing.Name = "Shirt"
10          Instance.new("Pants",player)
11          player.Clothing.Name = "Pants"
12          player:FindFirstChild("Shirt").ShirtTemplate = "http://www.roblox.com/asset/?id=28574189"
13          player:FindFirstChild("Pants").PantsTemplate = "http://www.roblox.com/asset/?id=28572684"
14     if player:FindFirstChild("Shirt Graphic") then
15               player:FindFirstChild("Shirt Graphic"):Destroy()
16    end
17end
18 
19 
20script.Parent.ClickDetector.MouseClick:Connect(onClicked)

However, upon clicking the brick, nothing happens. No errors in the console, the script doesn't even run. And yes, I do have an active click detector within the part I'm testing with, the mouse even changes to the click. I feel like I'm missing something, but I can't quite tell what.

1 answer

Log in to vote
1
Answered by 5 years ago

It is seemed like you are checking shirt, pant in the player, not character. This is how you get character by Player

1Player.Character

So now you will add .Character Before : WaitForChild at line 5 & 2. Hope that helped you

0
This fixed it, thank you so much! flamethower2002 50 — 5y
Ad

Answer this question