(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.
local suit = game.ReplicatedStorage.amongus:Clone() -- sus 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 character.Torso.Transparency = 1 character.Head.Transparency = 1 character["Left Arm"].Transparency = 1 character["Right Arm"].Transparency = 1 character["Left Leg"].Transparency = 1 character["Right Leg"].Transparency = 1 for _, child in pairs(character:GetChildren()) do -- iterates over each object within the character if child:IsA("Accessory") then -- checks if the object is an accessory child:Destroy() end end character.Head.face:Destroy() suit.Parent = player.character.Torso script.Parent.ClickDetector.MaxActivationDistance = 32 end end end) end)
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.
local suit = game.ReplicatedStorage.amongus:Clone() -- sus 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 for _, child in pairs(character:GetChildren()) do -- iterates over each object within the character if child:IsA("Accessory") then -- checks if the object is an accessory child:Destroy() 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... child.Transparency=1 end end character.Head.face:Destroy() suit.Parent = player.character.Torso script.Parent.ClickDetector.MaxActivationDistance = 32 end end end) end)
I hope this helped! If this helped don't forget to accept this answer. - Sulu710