I'm trying to make a script that allows the player to release their mouse when they press "R", but it's not working. I'm using an IntValue (parented to the script) as a detection mechanism (if the value is 0, then it's false. If the value is 1, it's true,) I don't need anybody to rewrite the script, I just need to know what to change about it.
local Player = game.Players.LocalPlayer
local UIS = game:GetService("UserInputService")
local PlayerGUI = Player:WaitForChild("PlayerGui")
local IsReleasing = script.IsReleasing.Value
UIS.InputBegan:Connect(function(Input)
if Input.KeyCode == Enum.KeyCode.R and IsReleasing == 1 then
IsReleasing = 0
local GUI = Instance.new("TextButton")
if GUI.Modal == false then
GUI.Parent = PlayerGUI.ScreenGui
GUI.Transparency = 1
GUI.Modal = true
elseif IsReleasing == 0 then
GUI.Modal = false
print("Worked")
IsReleasing = 1
end
end
end)
This script is parented to StarterPlayerScripts.
EDIT:
local Player = game.Players.LocalPlayer
local UIS = game:GetService("UserInputService")
local PlayerGUI = Player:WaitForChild("PlayerGui")
UIS.InputBegan:Connect(function(Input)
local IsReleasing = script.IsReleasing
if Input.KeyCode == Enum.KeyCode.R and IsReleasing.Value == 1 then
IsReleasing.Value = 0
local GUI = Instance.new("TextButton")
if GUI.Modal == false then
GUI.Parent = PlayerGUI.ScreenGui
GUI.Transparency = 1
GUI.Modal = true
elseif IsReleasing.Value == 0 then
GUI.Modal = false
print("Worked")
IsReleasing.Value = 1
end
end
end)

1 comment
It worked! Thank you so much for all the help! I really appreciate it!