Question about mouse script for button1up

so i have a basic function and im not sure on how to do this but the function basically makes shooting = false but i want to add on to it by making it where it does not make shooting false if there is some other variable is true

mouse.Button1Up:Connect(function()
shooting = false

I assume you want something like this?

Instance.RBXScriptSignal:Connect(function(...) -- the event signal
   if otherCondition then -- checks if the other variable is 'true'
      -- some other variable is 'true'
   else
      -- it's not 'true'
   end
end)
1 Like

what is rbx signal im confused

RBXScriptSignal is just the signal the script detects. For example, Mouse.Button1Down.

im having problems with my automatic gun script rn

deleted eeeeeeeeeeeeeeeeeeeeee

Could we see your Gun Script so that we can help you?

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local gun = script.Parent
local db = true
local equipped = false
local shooting = false
local mouseConnection
local value = script.Parent:WaitForChild("Value")
local MAX_VALUE = 17
local rld = 3
local debounce = false
local Up = false

gun.Equipped:Connect(function()
	equipped = true
	mouseConnection = mouse.Button1Down:Connect(function()
		shooting = true
		while shooting and equipped do
			script.Parent.Fire:FireServer(mouse.Hit.p)
			game.Workspace.AR15:Play()
			if value.Value == MAX_VALUE then
				print("clicked 10 times. resting value")
				value.Value = 0
			else
				value.Value += 1
				print("clicked times: "..tostring(value.Value))
				
				if value.Value == MAX_VALUE then
					local Up = true
					if shooting then 
						shooting = false 
						wait(3)
						shooting = true
					end
				end
			end
			--Release
			
			mouse.Button1Up:Connect(function()
				shooting = false
				if Up == false then
				else
					shooting = false
				end
			end)
			wait(0.15)
		end
	end)
end)
gun.Unequipped:Connect(function()

	equipped = false

	mouseConnection:Disconnect()

end)
1 Like

do you need any other scripts e

basically you want to do

if mouse.Button1Up:Connect(function() && somevariable = true
shooting = false
end

im not really a coder but thats what you wanna do right @HugeCoolboy2007 i think thats what he wanna do @Jackscarlett

right?

to explain if only button is up but not somevar then it wont work that is what i want

but if both are true/pressed then it will work

Personally I’d just use a while true do loop & frequently check if specific bool values are true or not

local RunService = game:GetService("RunService")
local UIS = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local gun = script.Parent
local db = true
local equipped = false
local shooting = false
local mouseConnection
local value = script.Parent:WaitForChild("Value")
local MAX_VALUE = 17
local rld = 3
local debounce = false
local Up = false

gun.Activated:Connect(function()
    UIS.InputBegan:Connect(function(Input, Chatted)
        if Chatted then
            return
        end
        shooting = true
    end)
end)

UIS.InputEnded:Connect(function(Input, Chatted)
    if Chatted then
        return
    end
    shooting = false
end)

gun.Unequipped:Connect(function()
    shooting = false
end)

while true do
    if shooting == true then
        script.Parent.Fire:FireServer(mouse.Hit.Position)
        workspace.AR15:Play()
        
        if value.Value == MAX_VALUE then
            print("clicked 10 times. resting value")
            value.Value = 0
        else
            value.Value += 1
            print("clicked times: "..tostring(value.Value))
        end
        wait(.15)
    end
    RunService.RenderStepped:Wait()
end

Maybe try this?

Yeah, I’m not really that much of a scripter.

it freezes sometimes do you mind if i message you the model?

it also needs to have the ammo system i use

oops i meant the reloading sytem

Gun.rbxm (5.1 KB)
Try this then?

FINALLY, anyways thank you so much!

1 Like

I have been stuck on this for the whole day