How do I find "Head" inside of a few Models and turn its Transparency = 0?
How would I make ascript to go into models (with different names) and find a Part named "Head" inside them? And then turn them Transparency = 0?
02 | owner = script.Parent.Parent.Parent.OwnerName |
04 | function onTouched(hit) |
08 | local check = hit.Parent:FindFirstChild( "Humanoid" ) |
11 | local user = game.Players:GetPlayerFromCharacter(hit.Parent) |
12 | local cost 1 = script.Parent.Cost |
13 | local cost = user:FindFirstChild( "leaderstats" ):FindFirstChild( "Dollars" ) |
14 | local user = game.Players:GetPlayerFromCharacter(hit.Parent) |
16 | if (user:FindFirstChild( "House" ) ~ = nil ) then |
17 | local user = game.Players:GetPlayerFromCharacter(hit.Parent) |
18 | user.PlayerGui:FindFirstChild( "AlreadyOwn" ).Frame.Visible = true |
20 | elseif user:FindFirstChild( "leaderstats" ).Dollars.Value > = cost 1. Value then |
21 | owner.Value = hit.Parent.Name |
22 | cost.Value = cost.Value - cost 1. Value |
25 | for i, v in pairs (script.Parent.Parent.Parent:GetChildren()) do |
26 | if v:IsA( "Model" ) then |
27 | for ii, vv in pairs (v:GetChildren()) do |
28 | if vv.Name = = "Head" then |
31 | local own = Instance.new( "NumberValue" ) |
34 | own.Value = script.Parent.Sell.Value |
35 | local ownshouse = Instance.new( "NumberValue" ) |
36 | ownshouse.Name = "OwnsHouse" |
37 | ownshouse.Parent = user |
38 | ownshouse.Value = script.Parent.Parent.Parent:FindFirstChild( "Value" ).Value |
39 | user.PlayerGui:FindFirstChild( "HousePurchase" ).Frame.Visible = true |
40 | script.Parent.Parent.Ad:remove() |
41 | script.Parent.Parent:remove() |
42 | local home = game.ServerStorage.Home 2 |
43 | home.Parent = game.Workspace |
45 | elseif user:FindFirstChild( "leaderstats" ).Dollars.Value < cost 1. Value then |
46 | user.PlayerGui.NotEnough.Frame.Visible = true |
63 | script.Parent.Touched:connect(onTouched) |
70 | Script: 33 : attempt to index field 'Parent' (a nil value) |