Hello, i have this script that detects if theres any input and if the button is pressed. It works works the button is pressed. But if you press a mouse button and its not pressing the button, the entire script just messes up, I want it to detect if theres input but only with the button
UserInputService.InputBegan:Connect(function(input, Typing)
if Typing then return end
if script.Parent.ImageButton.IfEquiped.Value == true then
player.PlayerGui.Slots.Frame[script.Parent.ImageButton.SlotOn.Value].PressToEquip.MouseButton1Click:Connect(function()
if AbilityReady == false then
script.Parent.ClapSound:FireServer(Character)
script.Parent.HandSignSound:FireServer(Character)
player.PlayerGui.Ability.Frame:FindFirstChild("Name").Text = script.Parent.Name
player.PlayerGui.Ability.Frame.Description.Text = script.Parent.ImageButton.Description.Value
player.PlayerGui.Ability.Frame[script.Parent.ImageButton.LeftClick.Value].Visible = true
print("Ablitiy ready for activation")
AbilityReady = true
ReadyAnim:Play()
player.PlayerGui.Ability.Frame:TweenPosition(
UDim2.new(0.313, 0, 0.83, 0),
"In",
"Linear",
0.1,
false
)
wait(0.1)
script.Parent.SetImage:FireServer(Character)
elseif AbilityReady == true then
script.Parent.RemoveImage:FireServer(Character)
AbilityReady = false
script.Parent.Blue:FireServer(Character)
print("Ablitiy not ready for activation")
player.PlayerGui.Ability.Frame[script.Parent.ImageButton.LeftClick.Value].Visible = false
ReadyAnim:Stop()
TigerAnim:Stop()
RamAnim:Stop()
SnakeAnim:Stop()
MonkeyAnim:Stop()
BoarAnim:Stop()
HorseAnim:Stop()
BirdAnim:Stop()
OxAnim:Stop()
RatAnim:Stop()
hareAnim:Stop()
DogAnim:Stop()
DragonAnim:Stop()
state = 0
for i,v in pairs(player.PlayerGui.Ability.Frame[script.Parent.ImageButton.LeftClick.Value]:GetChildren()) do
v.TextColor3 = Color3.new(0, 0, 0)
end
player.PlayerGui.Ability.Frame:TweenPosition(
UDim2.new(0.313, 0, 1, 0),
"In",
"Linear",
0.1,
false
)
end
end)
end
end)
just ignore all that extra stuff, thats the stuff that gets messed up
Oh no, i need the input began. So when it detects input it checks if the value is equal to true, The second function with the MouseButton1Click wont work if the value is equal to true, so i need it to detect each time to determine
player.PlayerGui.Slots.Frame[script.Parent.ImageButton.SlotOn.Value].PressToEquip.MouseButton1Click:Connect(function()
if not script.Parent.ImageButton.IfEquiped.Value then return end
--code
end)
They can click the button either way. You never disabled the button in any way. There is no way to completely disable a button as far as I know. Also, your code continues to stack click events on top of each other, causing problems.