Tool not working for mobile users

i made a bubble gun that emits particles and sound when clicked , everything works perfectly on pc but for mobile users only the particles dont emit when tapped on the tool except the sound and animation works perfectly. Heres the script what should i change for it to work the same on mobile?

local Handle = Tool.Handle
local Emitter = script.Parent.Barrel.Water
local Sound = Handle.Bubbles1Loop

Tool.Activated:Connect(function()
	Sound.Playing = true
	Emitter.Enabled = true
	wait(2)
	Emitter.Rate = 210
end)

Tool.Deactivated:Connect(function()
	Sound.Playing = false
	Emitter.Enabled = false
end)

Tool.Unequipped:Connect(function()
	Sound.Playing = false
	Emitter.Enabled = false
end)

The problem is the event activatd. Activated is not working for mobile.

1 Like

yeah i thought so ^^ now what do i use instead of activated so it works for mobile and pc both? :slight_smile:

Sure! Before you will have to find out if your player is on mobile or PC. For this you should use the userinputservice to clarefie, if the player is on PC or mobile with this script:

local UserInputService = game:GetService(“UserInputService”)

if UserInputService.KeyboardEnabled and UserInputService.MouseEnabled then
print(“Player is on a PC”)
elseif UserInputService.TouchEnabled then
print(“Player is on a mobile device”)
else
print(“Player is on an unknown device”)
end

1 Like

If player was on PC you can keep using activated.
If he was on mobile you should use the TouchTap event.
It is the same as Activated but for touchscreens.

2 Likes

thank you, i see that userinputservice could be used , i dont know how to modify it for my code , do u mind if u can spare a moment to modify my code please?

1 Like