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

Why wont this script destroy scripts placed inside a player?

script.Parent.MouseButton1Click:connect(function()
local pup = game.ReplicatedStorage.Jump:Clone()
local cup = game.ReplicatedStorage.Jump:Clone()
	
	--CONDITIONS
	print("k")
	if  script.Parent.Equip.Text == "Equip!" and script.Parent.Parent.Value.Value == "0" then
    print("YESSSSSS")
	
	--CODE
	script.Parent.Equip.Text = "Unequip!"
	script.Parent.Parent.Value.Value = "1"
	pup.Parent = game.Players.LocalPlayer.Backpack
    cup.Parent = game.StarterPlayer.StarterCharacterScripts
	script.Parent.Parent.Parent.Parent.Abdisp.Image = "rbxgameasset://Images/jkj"
	
	
	--UNEQUIP
	elseif script.Parent.Equip.Text == "Unequip!" and script.Parent.Parent.Value.Value == "1" then
		script.Parent.Parent.Value.Value = "0"
		script.Parent.Equip.Text = "Equip!"
		script.Parent.Parent.Parent.Parent.Abdisp.Image = ""
		pup:Destroy()
		cup:Destroy()
		
	elseif script.Parent.Equip.Text == "Equip!" and script.Parent.Parent.Value.Value == "1" then
		script.Parent.Equip.Text = "An abilility is already equiped!"
		wait(2)
		script.Parent.Equip.Text = "Equip!"
	end
	end)

the script places scripts inside players just fine, but wont delete them. What is wrong here?

1 answer

Hi!

Whether or not you are equipping or unequipping, it will still clone the scripts since they are on the very top. When you are unequipping the script and you tell it to destroy "pup" and "cup" on lines 23 and 24, all you are doing is destroying the non-parented script you just cloned. If you want to delete the scripts that were already there in the BackPack and StarterCharacterScripts, you have to delete what's actually there.

script.Parent.MouseButton1Click:connect(function()

    --CONDITIONS
    print("k")
    if  script.Parent.Equip.Text == "Equip!" and script.Parent.Parent.Value.Value == "0" then
    print("YESSSSSS")

    --CODE
--Variables go here so they are only cloned when you are EQUIPPING!
local pup = game.ReplicatedStorage.Jump:Clone()
local cup = game.ReplicatedStorage.Jump:Clone()
    script.Parent.Equip.Text = "Unequip!"
    script.Parent.Parent.Value.Value = "1"
    pup.Parent = game.Players.LocalPlayer.Backpack
    cup.Parent = game.StarterPlayer.StarterCharacterScripts
    script.Parent.Parent.Parent.Parent.Abdisp.Image = "rbxgameasset://Images/jkj"


    --UNEQUIP
    elseif script.Parent.Equip.Text == "Unequip!" and script.Parent.Parent.Value.Value == "1" then
        script.Parent.Parent.Value.Value = "0"
        script.Parent.Equip.Text = "Equip!"
        script.Parent.Parent.Parent.Parent.Abdisp.Image = ""
game.Players.LocalPlayer.Backpack:FindFirstChild("Jump"):destroy() --Destroy the backpack script
game.StarterPlayer.StarterCharacterScripts:FindFirstChild("Jump"):destroy() --Destroy the StarterCharacterScripts script


    elseif script.Parent.Equip.Text == "Equip!" and script.Parent.Parent.Value.Value == "1" then
        script.Parent.Equip.Text = "An abilility is already equiped!"
        wait(2)
        script.Parent.Equip.Text = "Equip!"
    end
    end)

1 comment

0

I actually figured it out myself. The script i wanted to destroy was actually being destroyed, but the script wrote to certain properties. I forgot whatever a script does will no be reversed when it's destoryed XD. I'm so stupid. Thanks for your response though

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