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