Hello. I’m making a system that checks for a tool inside of a players backpacks and asks them if they want to remove it. It activates upon touching an invisible area around the trashcan and prompts the user with a GUI while freezing their movement. Issue is that once the player closes the GUI it doesn’t enable their movement back. What’s the issue? Do I need to check that the movement has been disabled on the script that enables it?
GUI PROMPTING SCRIPT
local player = game:GetService("Players")
local trash = game.Workspace.TrashDetector
local gui = player.LocalPlayer.PlayerGui.CardDelete.Frame
local playerModule = require(game.Players.LocalPlayer.PlayerScripts:WaitForChild("PlayerModule"))
local controls = playerModule:GetControls()
local touched = false
trash.Touched:Connect(function()
if touched == false then
gui.Visible = true
controls:Disable()
wait(2)
touched = true
else
touched = false
end
end)
GUI SCRIPT
local TextButton = script.Parent
local gui = script.Parent.Parent
local player = game:GetService("Players").LocalPlayer
local playerModule = require(game.Players.LocalPlayer.PlayerScripts:WaitForChild("PlayerModule"))
local controls = playerModule:GetControls()
TextButton.MouseButton1Click:Connect(function()
local Character = player.Character or player.CharacterAdded:Wait()
local Backpack = player:FindFirstChild("Backpack")
local Card = Backpack:FindFirstChild("Lottery Card") or Character:FindFirstChild("Lottery Card")
if Card then
controls:Enable()
Card:Destroy()
gui.Visible = false
else
gui.Visible = false
end
end)
picture of explorer (the other script is inside of StarterGui):