Script doesn’t work after resetting

  1. What do you want to achieve? Fix a script that doesn’t work after resetting.

  2. What is the issue? Script works if you haven’t reset, if you do reset the script doesn’t work.


local Tools = {
    'Taser',
    'Baton',
    'Glock 19',
    'Tackle',
    'Handcuffs',
    'Grab',
    'Frisk',
    'Flashlight',
    '',
    'Cones',

}


script.Parent.RemoteEvent.OnServerEvent:Connect(function(Player)
        if Cooldown == true then return end
        Cooldown = true
        if Player:IsInGroup(script.Parent.IsRestricted.Value) then
            for _,tool in pairs(Player.Backpack:GetChildren()) do
                for _,v in pairs(Tools) do
                    if tool.Name == v then
                        tool:Destroy()
                    end
                end
            end
            for _,v in pairs(Tools) do
                game.ServerStorage.Weapons[v]:Clone().Parent = Player.Backpack
            end
        end
        wait(.5)
        Cooldown = false
        
    end)

You need to provide more context on where this script exists in your place and what it’s purpose is for creating gameplay. What does it mean for the script to “be working”? Have you tried adding print calls here and there?

The script is in a part, when F is clicked it will fire a remote and the script in the part will detect it and run the script.

Maybe the code that fires the RemoteEvent is broken. Perhaps you should post that code too.

local Parents = script.Parent
local RE = Parents:WaitForChild("RemoteEvent")
local IR = Parents:WaitForChild("IsRestricted")
local Cooldown = false
local Storage = game:GetService("ServerStorage")
local Weapons = Storage:WaitForChild("Weapons")

local Tools = {
	'Taser',
	'Baton',
	'Glock 19',
	'Tackle',
	'Handcuffs',
	'Grab',
	'Frisk',
	'Flashlight',
	'Cones'
}


RE.OnServerEvent:Connect(function(Player)
	if Cooldown then
		return
	end
	
	Cooldown = true
	if Player:IsInGroup(IR.Value) then
		local Backpack = Player.Backpack
		for _, tool in ipairs(Backpack:GetChildren()) do
			if table.find(tool.Name, Tools) then
				Backpack:FindFirstChild(tool.Name):Destroy()
				Weapons:FindFirstChild(tool.Name):Clone().Parent = Backpack
			end
		end
	end
	task.wait(0.5)
	Cooldown = false
end)

I cleaned things up a bit, could you provide the local script which is firing the server?

The last item in the array doesn’t require a comma after it, there were some other minor fixes too.