Why does this script not work on mobile?

I have a script that is supposed to fire an event when you click or tap a player. It works perfectly fine on PC, but on mobile, it’s not working at all.

Here’s my script:

local players = game.Players
local plr = players.LocalPlayer
local char = plr.Character
local UIS = game:GetService("UserInputService")
local EffectsEvent = game.ReplicatedStorage.RemoteEvents.SFX
local DB = false
local Mouse = plr:GetMouse()

local debounce = false

game.ReplicatedStorage.RemoteEvents.ClientEvents.Incendia.OnClientEvent:Connect(function()
	local connect
	connect = UIS.InputBegan:Connect(function(key)
		if key.UserInputType == Enum.UserInputType.MouseButton1 or key.UserInputType == Enum.UserInputType.Touch then
			print("clicked")
			if debounce == true then
				game.StarterGui:SetCore("SendNotification", {
					Title = "Notification";
					Text = "This spell is on cooldown."
				})
				connect:Disconnect()
			else
				if key.UserInputType == Enum.UserInputType.MouseButton1 then
					print("clicked")
					if debounce == false then
						if Mouse.Target.Parent:FindFirstChild("Humanoid") then
							if (Mouse.Target.Parent.HumanoidRootPart.Position - char.HumanoidRootPart.Position).Magnitude < 50 then
								if char.Humanoid.CanUseMagic.Value == true then
									debounce = true
									connect:Disconnect()
									game.ReplicatedStorage.RemoteEvents.Abilities:FireServer("Incendia",Mouse.Target)
									wait(20)
									debounce = false
								end
							end
						end
					end
				end
			end
		end
	end)
end)
1 Like

Does it still recieve the event? Is clicked outputted to the console?

This should work fine, I went into studio and tested it out.

Theres likely an outside force messing with your script, it seems to work perfectly fine for me. (Of course, It may be caused by the event, but I think thats unlikely.)

yeah everything prints, it literally just doesnt work on mobil.e

i don’t see what could be messing with it though. I haven’t tested it myself but the person I asked to test it said it didnt work