Tool.Activated Not Firing on Mobile

For a flamethrower tool, I want fire to shoot when the player is holding down their mouse or their finger in the case of mobile users. It works fine on PC, but on tablet (haven’t tested on phone), “FLAMES ACTIVATED” and “FLAMES DEACTIVATED” don’t print.

The code:

local particles = script.Parent:WaitForChild("Muzzle"):WaitForChild("ParticleEmitter")

particles.Enabled = false

script.Parent:WaitForChild("Hitbox").Touched:Connect(function() end)


script.Parent.Activated:Connect(function()
	print("FLAMES ACTIVATED")
	particles.Enabled = true
	
	particles.Parent.Sound:Play()
	
	
	while particles.Enabled == true do
		
		wait(0.5)
		
		local parts = script.Parent.Hitbox:GetTouchingParts()
		
		local humanoidsDamaged = {}
		
		for i, part in pairs(parts) do
		
			if part.Parent:FindFirstChild("Humanoid") and not humanoidsDamaged[part.Parent.Humanoid] then
				
				humanoidsDamaged[part.Parent.Humanoid] = true
				
				part.Parent.Humanoid:TakeDamage(20)
			end
		end
	end
end)

script.Parent.Deactivated:Connect(function()
	print("FLAMES DEACTIVATED")
	particles.Enabled = false
	
	particles.Parent.Sound:Stop()
end)

Is this a local script or server script?

It is a server script.

Xxxxxx char

Use a local script it and should fix your problem.

I tried this and all the prints print correctly, but the fire particles still don’t appear.

My new code:

LocalScript:

script.Parent.Activated:Connect(function()
	print("FLAMES ACTIVATED client")
	game.ReplicatedStorage.FlamesActivated:FireServer()
end)

script.Parent.Deactivated:Connect(function()
	print("FLAMES DEACTIVATED client")
	game.ReplicatedStorage.FlamesDeactivated:FireServer()
end)

ServerScript:

local particles = script.Parent:WaitForChild("Muzzle"):WaitForChild("ParticleEmitter")

particles.Enabled = false

script.Parent:WaitForChild("Hitbox").Touched:Connect(function() end)


game.ReplicatedStorage.FlamesActivated.OnServerEvent:Connect(function()
	print("FLAMES ACTIVATED server")
	particles.Enabled = true
	
	particles.Parent.Sound:Play()
	
	
	while particles.Enabled == true do
		
		wait(0.5)
		
		local parts = script.Parent.Hitbox:GetTouchingParts()
		
		local humanoidsDamaged = {}
		
		for i, part in pairs(parts) do
		
			if part.Parent:FindFirstChild("Humanoid") and not humanoidsDamaged[part.Parent.Humanoid] then
				
				humanoidsDamaged[part.Parent.Humanoid] = true
				
				part.Parent.Humanoid:TakeDamage(20)
			end
		end
	end
end)

game.ReplicatedStorage.FlamesDeactivated.OnServerEvent:Connect(function()
	print("FLAMES DEACTIVATED server")
	particles.Enabled = false
	
	particles.Parent.Sound:Stop()
end)

Using UserInputService fixed the issue.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.