Disabling weapons and tools at ATM

I have script for ATM (Bankomat)
But I can’t turn off the tools.

print("OTEVRIT Bankomat GUI")

local Players = game:GetService("Players")
local player = Players.LocalPlayer

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local OpenBankomat = ReplicatedStorage.RemoteEvents.OpenBankomat
local CloseBankomat = ReplicatedStorage.RemoteEvents.CloseBankomat

local hlavak = script.Parent
local Frame = hlavak:WaitForChild("Frame")
local BG = hlavak:WaitForChild("BG")

local storedTools = {}

local function disablePlayerMovement()    ---- Deaktivuje POHYB hráče 
    local character = player.Character or player.CharacterAdded:Wait() -- References Character or waits for it to load in if it doesn't exist yet
    if character then
        local humanoidRootPart = character:FindFirstChild("HumanoidRootPart")
        if humanoidRootPart then
            humanoidRootPart.Anchored = true -- Uzamkne hráče na místě
        end

        local controls = require(player.PlayerScripts:WaitForChild("PlayerModule")):GetControls()
        controls:Disable() -- Vypne kontrolu pohybu hráče
    end
end

local function enablePlayerMovement()    ---- Aktivuje POHYB hráče 
    local character = player.Character or player.CharacterAdded:Wait()
    if character then
        local humanoidRootPart = character:FindFirstChild("HumanoidRootPart")
        if humanoidRootPart then
            humanoidRootPart.Anchored = false -- Uvolní hráče na místě
        end

        local controls = require(player.PlayerScripts:WaitForChild("PlayerModule")):GetControls()
        controls:Enable() -- Zapne kontrolu pohybu hráče
    end
end

local function storeAndRemoveTools()
    storedTools = {} -- Reset stored tools

    local backpack = player:WaitForChild("Backpack")
    local character = player.Character or player.CharacterAdded:Wait()

    -- Store tools from Backpack
    for _, tool in ipairs(backpack:GetChildren()) do
        if tool:IsA("Tool") then
            table.insert(storedTools, tool)
            tool.Parent = ReplicatedStorage -- Move tool to ReplicatedStorage
        end
    end

    -- Store tools from Character
    for _, tool in ipairs(character:GetChildren()) do
        if tool:IsA("Tool") then
            table.insert(storedTools, tool)
            tool.Parent = ReplicatedStorage -- Move tool to ReplicatedStorage
        end
    end
end

local function restoreTools()
    for _, tool in ipairs(storedTools) do
        tool.Parent = player:FindFirstChild("Backpack") or player:FindFirstChild("StarterGear") -- Restore tool to Backpack or StarterGear
    end
    storedTools = {} -- Clear stored tools
end

OpenBankomat.OnClientEvent:Connect(function(proximityPrompt)
    Frame.Visible = true
    BG.Visible = true
    proximityPrompt.Enabled = false

    disablePlayerMovement() -- Zamezíme hráči pohyb
    storeAndRemoveTools() -- Odebereme všechny nástroje
end)

CloseBankomat.OnClientEvent:Connect(function()
    Frame.Visible = false
    BG.Visible = false

    enablePlayerMovement() -- Uvolníme pohyb hráče
    restoreTools() -- Vrátíme všechny nástroje
end)

video example:

Where am I making mistake ??

Thanks in advance

Codycheck

First of all remove the table for the stored tools and make a new folder in replicatestorage. Make it so there it puts all tools, then just do i,v for that folder so you know that’s working.

I already have this option that the tools are stored and removed from the inventory and renewed after the ATM closed

But I create something similar in the shop and there is impractical to hide the tools

Cody

Can’t you just hide the hotbar when the ATM UI gets opened?

Think about it this way fixing game script

What is hotbar…???
Like the whole backpack

You can disable the inventory with this:

game:GetService("StarterGui"):SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)
2 Likes

I believe you should just destroy the tools when you want to remove them, after storing them in a table. Then when you want to restore the tools, you loop through “storedTools” find the name of the tool, then look for the tool in whereever you keep all your weapons(like a shop folder or something.) After you find the tool, just clone it and set its parent to where ever you like. I think mainly if you just move their tools into replicated storage, and they leave midway in game, the tools will just stay there which won’t be efficient.

1 Like

And you can think of how to fix it ??