local uis = game:GetService("UserInputService")
local down = false
uis.InputEnded:Connect(function(inp,gnp)
if inp.UserInputType == Enum.UserInputType.MouseButton1 then
print('up')
down = false
end
end)
local usedmain = false
uis.InputBegan:Connect(function(inp,gnp)
if gnp then return end
if inp.UserInputType == Enum.UserInputType.MouseButton1 then
local down = true
while down and wait() do
print('down')
end
end
end)
That’s my script, and the output just keeps repeating “down” even after I released my mouse.
local uis = game:GetService("UserInputService")
local down = false
uis.InputEnded:Connect(function(inp,gnp)
if inp.UserInputType == Enum.UserInputType.MouseButton1 then
print('up')
down = false
end
end)
local usedmain = false
uis.InputBegan:Connect(function(inp,gnp)
if gnp then return end
if inp.UserInputType == Enum.UserInputType.MouseButton1 then
down = true
end
end)
while wait() do
if down then
print('down')
end
end
**local down = false
uis.InputBegan:Connect(function(inp,gnp)
if inp.UserInputType == Enum.UserInputType.MouseButton1 then
down = true
while down and wait() do
print('down')
end
end
end)
uis.InputEnded:Connect(function(inp,gnp)
if inp.UserInputType == Enum.UserInputType.MouseButton1 then
print('up')
down = false
end
end)
Yet the output shows:
down (x4)
up
down
Why is that, even after I release it still detects down once?