Hello, In my script, I want to see if a different accessory is on my character, and if it is, I want it to destroy that accessory and add another. How do I do this?
Thank you, Kreativle
Hello, In my script, I want to see if a different accessory is on my character, and if it is, I want it to destroy that accessory and add another. How do I do this?
Thank you, Kreativle
Try this.
local AccessoryName = "Accessory Name" --Put whatever the name of the accessory is in here
game.Players.PlayerAdded:Connect(function(Player) --Will do the function to the player that joins the game
local AccessoryCheck = Player.Character:FindFirstChild(AccessoryName) --Will search the player's character model to see if they have the name of the accessory
if AccessoryCheck then
AccessoryCheck:Destroy() --Will delete the accessory from the game
end
end
In the brackets is the name "Player". It is the variable which tells the game which player just joined.
Player.Character will be nil, you need to wait for the characteradded event
This discussion is preserved as it was. New answers, comments, and votes are closed.
1 comment
if workspace:FindFirstChild("something") then workspace:FindFirstChild("something"):Destroy() end