User Input Service not reading

I’m trying to make a throwing system where you equip a ball tool, hold your mouse, and let it go to shoot the ball. When I use the tool, it fires an event that activates a server-side script that has an rng system to decide which ball to use because there are different variations of the ball. When the system decides, it calls a module respective to the ball it chose. User input service inside the module does not read whether my mouse is down or not while I have the mouse held down.

local rs = game:GetService("ReplicatedStorage")
local debris = game:GetService("Debris")
local tweenS = game:GetService("TweenService")
local uis = game:GetService("UserInputService")

local function greenball(player)
	local char = player.Character
	local ball = rs.Balls.greenball:Clone()
	local size = ball.Size
	ball.Parent = game.Workspace
	size = Vector3.new(0.1,0.1,0.1)
	ball.CanCollide = false

	local ballTweenInfo = TweenInfo.new(0.6, Enum.EasingStyle.Elastic, Enum.EasingDirection.Out, 0, false, 0)
	local newSize = Vector3.new(5,5,5)
	local tween = tweenS:Create(ball, ballTweenInfo, {Size = Vector3.new(3,3,3)})

	tween:Play()

	local arm = player.Character:FindFirstChild("Right Arm")
	local weld = Instance.new("Weld")
	weld.Parent = ball
	weld.Part0 = arm
	weld.Part1 = ball
	ball.CFrame =  arm.CFrame * CFrame.new(0,-2.5,0)
	weld.C0 = CFrame.new(0,-2.5,0)
		
	uis.InputBegan:Connect(function(input, GameProcessedEvent)
		while uis:IsMouseButtonPressed(Enum.UserInputType.MouseButton1) do
			task.wait()
			print('a')
		end
	end)
	
end

return greenball

This is the module for one of the ball variants. It spawns the ball into my hand, but UIS isn’t detecting that my mouse is down.

1 Like

Inputended wouldnt be used for this as this detects the end of the input, you would likely want inputbegan

1 Like

It uses inputBegan now. I was experimenting with it and forgot to change it back for this post.

1 Like