Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

(SOLVED) My script won't delete a CERTAIN hat once a block is clicked?

(EDIT: From what I can see, a error pops up in Line 1 located in the Output.)

19:48:50.040 - Infinite yield possible on 'Players.dynamitebirthday:WaitForChild("Character")'
19:48:50.042 - Stack Begin
19:48:50.043 - Script 'Workspace.DominusAureus.Script', Line 2
19:48:50.045 - Stack End

I am currently making this game and as a gamepass test, I made a gamepass which, once purchased, gives the user that purchased it a Dominus Aureus. Problem is, I know many users would want this hat taken off at any point. So, I came up with an idea to make a block, (which includes a ClickDetector and a Script). This script's function would be to remove the dominus, ("GoldenDominus") from the player's accessories in-game. Problem is, once the block has been clicked, nothing happens. I came to the Scripting Helpers Discord for help, and simply got ignored. I came to my friends for help, and they tried all they could do. I had no idea what else to do, except ask here. Any advice on how to fix this? (FYI: The block that I click is named "DominusAureus".)

game.Workspace.DominusAureus.ClickDetector.MouseClick:Connect(function(plr)
    local char = plr:WaitForChild("Character")
    local dom = char:FindFirstChild("GoldenDominus")
    if dom ~= nil then

        dom:Destroy() 
    end
end) 

7 comments

0

i'm not really sure, try just doing if dom then; if dom ~= is alwyas right but just try it

0

What is the error in the output?

0

also, try putting some prints inside the event and inside the if statment, just to check if stuff is working

1

Try replacing "local char = plr:WaitForChild("Character")" with "local char = plr.Character or plr.CharacterAdded:Wait()"

0

Try deleting the handles parent

0

I have no idea how to reply to comments, but here I go. (@2052Game, that doesn't appear to work.)

0

The accessory is exactly named “GoldenDominus”, right? If not, change line 3 to whatever the accessory is called.

1 answer

The problem in Line 1 was that "DominusAureus" should have been "Parent".

This discussion is preserved as it was. New answers, comments, and votes are closed.