Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why will the UserInputService not work?

Hello,

Here is the code I am trying to resolve:

local UserInputService = game:GetService("UserInputService")
local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()



UserInputService.InputBegan:connect(function(input, gameProcessedEvent)
	if input == Enum.UserInputType.MouseButton1 then
		print("worked")
		for _, v in pairs (script.Parent:GetChildren()) do
			if v.Name == "Fruxan_Pistol" then
				print("Pistol")
			end
			if v.Name == "Fruxan_Rifle" then
				print("Rifle")
			end
			if v.Name == "Fruxan_Rocket" then
				print("Rocket")
			end
		end
	end
end)

And here is the explorer. This script is located under "Purchasing". https://prnt.sc/vrgggx

I was thinking it was something to do with PlayerGui property or something but I would prefer someone to verify this would be the case and point me in the right direction.

Thanks.

1 comment

0

And here is the explorer. This script this script t h i s s c r i p t i think thats a typo

1 answer

✓ Accepted answer

You need to check the UserInputType, so what you do is:

if input.UserInputType == Enum.UserInputType.MouseButton1 then
	print("worked")
end

This discussion is preserved as it was. New answers, comments, and votes are closed.