(I was running low on character space so i cut off some extra characters, but the full question is ""How do I make this script so it makes the player invisible (accessories and faces) and clone this billboardgui into the character's torso if they have 200,000 cents leaderstat?)
I just need a fixed version of this script that makes the player Invisible and gets rid of their accessories and clones the billboardgui into the Torso?
My current code wont work:
local suit = game.ReplicatedStorage.amongus:Clone()
local price = 200000
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
script.Parent.ClickDetector.MouseClick:Connect(function(player)
if player.leaderstats.cents.Value >= price then
local txt = script.Parent.Text:Clone()
txt.Parent = player.PlayerGui
script.Parent.ClickDetector.MaxActivationDistance = 0
player.character.Torso.Transparency = 1
player.character.Head.Transparency = 1
player.character["Left Arm"].Transparency = 1
player.character["Right Arm"].Transparency = 1
player.character["Left Leg"].Transparency = 1
player.character["Right Leg"].Transparency = 1
player.character:FindFirstChildOfClass("Accessory"):Destroy()
player.character:FindFirstChildOfClass("Decal"):Destroy()
suit.Parent = player.character.Torso
script.Parent.ClickDetector.MaxActivationDistance = 32
end
end
any help is very much a p p r e c i a t e d !
(also talk like your talking to a baby bc im such a noob at scripting0
Goo goo gah gah! (I apologize in advance for the horrid joke)
To start, you forgot to capitalize the letter C in Character as capitalization matters! You actually don't even need to write player.character as character is already there for you with the CharacterAdded event. You also have written 'player.character:FindFirstChildOfClass("Accessory"):Destroy()' which will only find and destroy one object of the Accessory class. We'll add a for loop to take care of multiple Accessories.
01 | local suit = game.ReplicatedStorage.amongus:Clone() -- sus |
02 | local price = 200000 |
03 | game.Players.PlayerAdded:Connect( function (player) |
04 | player.CharacterAdded:Connect( function (character) |
05 | script.Parent.ClickDetector.MouseClick:Connect( function (player) |
06 | if player.leaderstats.cents.Value > = price then |
07 | local txt = script.Parent.Text:Clone() |
08 | txt.Parent = player.PlayerGui |
09 | script.Parent.ClickDetector.MaxActivationDistance = 0 |
10 |
11 | character.Torso.Transparency = 1 |
12 | character.Head.Transparency = 1 |
13 | character [ "Left Arm" ] .Transparency = 1 |
14 | character [ "Right Arm" ] .Transparency = 1 |
15 | character [ "Left Leg" ] .Transparency = 1 |
We can add an additional for loop, albeit unnecessary, to set the transparency of each part of the character. This'll reduce the number of lines in your code.
01 | local suit = game.ReplicatedStorage.amongus:Clone() -- sus |
02 | local price = 200000 |
03 | game.Players.PlayerAdded:Connect( function (player) |
04 | player.CharacterAdded:Connect( function (character) |
05 | script.Parent.ClickDetector.MouseClick:Connect( function (player) |
06 | if player.leaderstats.cents.Value > = price then |
07 | local txt = script.Parent.Text:Clone() |
08 | txt.Parent = player.PlayerGui |
09 | script.Parent.ClickDetector.MaxActivationDistance = 0 |
10 |
11 | for _, child in pairs (character:GetChildren()) do -- iterates over each object within the character |
12 | if child:IsA( "Accessory" ) then -- checks if the object is an accessory |
13 | child:Destroy() |
14 | elseif child:IsA( "Part" ) or child:IsA( "MeshPart" ) then -- checks if object is a part meshpart or, in other words, body part; I think you can use "BasePart", but I've never used it before so I dunno... |
15 | child.Transparency = 1 |
I hope this helped! If this helped don't forget to accept this answer. - Sulu710