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

How do I make this script destroy a tool in starterpack and a model in workspace?

So I made this script and put it into a gui button so that when it is clicked, a model from workspace is deleted. This works fine. However I also tried to make the script delete a tool from starterpack, but when I run the game and click the button, the script doesn't do anything. It no longer deletes the model from workspace nor does it delete a tool. here is the script.

wait(1)
script.Parent.MouseButton1Down:Connect(function()
	script.Parent.Parent:Destroy()
	game.StarterPack.M16:Destroy()
	for i, model in pairs(game.Workspace:GetChildren())do
		if string.match(model.name, "wasd")then
			model:Destroy()
		end
	end
end)

1 answer

The issue is you are trying to destroy from the starter pack, rather than the players inventory. Since Starter pack is replicated to all clients. So by destroying it from starter pack your stopping it from being replicated.

Pt2

wait(1)
script.Parent.MouseButton1Down:Connect(function()
    script.Parent.Parent:Destroy()
    game.Players.LocalPlayer.Backpack.M16:Destroy()
    for i, model in pairs(game.Workspace:GetChildren())do
        if string.match(model.name, "wasd")then
            model:Destroy()
        end
    end
end)

this will only work in a local Script. If theres any other issues explain them, and send the full script.

Don't forget if this helps to accept as answer.

6 comments

0

OH!!!

0

So I made a new script where I tried to remove it through the player's backpack. Nothing happened xd Can you show me what script you would make?

0

AAlright the answer will be updated in a few minutes

0

ok

0

Nothing happens. It's inside a local script that's inside a text button

0

Then I have no idea what the issue is it looks like it would work to me.

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