How to make this tool work on mobile

I Have this script & Local script of a tool, It’s working on PC But not on mobile.
What is wrong? Please help, thank you!

Script:

emitter = script.Parent.Muzzle.Emitter

function turnOn()

emitter.Pink.Enabled = true

emitter.Green.Enabled = true

emitter.Yellow.Enabled = true

emitter.Blue.Enabled = true

emitter.White.Enabled = true

emitter.Sound.Playing = true

end

function turnOff()

emitter.Pink.Enabled = false

emitter.Green.Enabled = false

emitter.Yellow.Enabled = false

emitter.Blue.Enabled = false

emitter.White.Enabled = false

emitter.Sound.Playing = false

end

script.Parent.Fire.OnServerEvent:Connect(function(ply, fire)

if fire then

turnOn()

else

turnOff()

end

end)

Local Script:

emitter = script.Parent.Muzzle.Emitter

function turnOn()

emitter.Pink.Enabled = true

emitter.Green.Enabled = true

emitter.Yellow.Enabled = true

emitter.Blue.Enabled = true

emitter.White.Enabled = true

emitter.Sound.Playing = true

script.Parent.Fire:FireServer(true)

end

function turnOff()

emitter.Pink.Enabled = false

emitter.Green.Enabled = false

emitter.Yellow.Enabled = false

emitter.Blue.Enabled = false

emitter.White.Enabled = false

emitter.Sound.Playing = false

script.Parent.Fire:FireServer(false)

end

script.Parent.Activated:Connect(turnOn)

script.Parent.Deactivated:Connect(turnOff)

script.Parent.Unequipped:Connect(turnOff)

1 Like

I don’t see the point of doing the same things in client and server side, also the “Tool.Activated” function should work on mobile too, just tap anywhere on the screen while the tool is equipped.

About the “Tool.Deactivated”, i’m not sure if it work for mobile, so you probably have to turn it off manualy after getting activated.
There is also another solution which is to create a mobile button using ContexActionService, then use this button to activate/desactivate the equipped tool.

local script

script.Parent.Activated:Connect(function()
	script.Parent.Fire:FireServer(true)
end)

script.Parent.Deactivated:Connect(function()
	script.Parent.Fire:FireServer(false)
end)

script.Parent.Unequipped:Connect(function()
	script.Parent.Fire:FireServer(false)
end)

Script:

Emit_Folder = script.Parent.Muzzle.Emitter

local function turnOn()	
	for _, Child in pairs(Emit_Folder:GetChildren())do
		if Child:IsA("ParticleEmitter")then
			Child.Enabled = true
		end
	end
	Emit_Folder.Sound:Play()
end

local function turnOff()
	for _, Child in pairs(Emit_Folder:GetChildren())do
		if Child:IsA("ParticleEmitter")then
			Child.Enabled = false
		end
	end
end

script.Parent.Fire.OnServerEvent:Connect(function(Player, Setting)
	if Setting == true then
		turnOn()
	elseif Setting == false then
		turnOff()
	end
end)
1 Like

It still doesn’t work, do you mind helping with the model? Here’s the model: Tool - Roblox

Change both instances of

To

1 Like