Im trying to make a cookie clicker kinda game, and i recently found out that MouseButton1Click event isn't supported on mobile. I've found a solution on Roblox Wiki, TouchTap event. I've used it in my script and everything worked except... When i tap on GUI that gives you money, instead of giving 1 money it gives me 2. I figured out that money per tap is doubled. Even when I buy an upgrade its money per tap is still doubled. Script i use is

local money = script.Parent.Parent:WaitForChild("Money")
local upgrade1 = script.Parent.Parent:WaitForChild("HasUpgrade1")
local multiplier = script.Parent.Parent:WaitForChild("Multiplier").Value
local upgrade2 = script.Parent.Parent:WaitForChild("HasUpgrade2")

if money then
	script.Parent.TouchTap:connect(function()
		money.Value = money.Value + 1*multiplier
		while true do
			wait(0.01)
			if upgrade1.Value == true and upgrade2.Value == true then
				multiplier = 8
			elseif upgrade2.Value == true then
				multiplier = 4
			elseif upgrade1.Value == true then
				multiplier = 2
			end
		end
	end)
end

I can easily remove that double value by dividing the multiplier by 2, but I don't really want. I want only to know if this is a Roblox bug or double tap is just a feature of this event, if so, do you know which connecting event should i use instead?

3 comments

0

Are you sure MouseButton1Click doesn't work on mobile? If both are in use, it could double the points given. I would recommend game:GetService("UserInputService") to detect the player's device information for cross platform compatibility.

0

Optikk, thank you, could you place your answer in "Answer this question" so i can make it answered

0

MouseButton1Click is supported on mobile it acts like a one tap