Cleaning system help

Im trying to make a cleaning system and this is my script

script.Parent.Equipped:Connect(function()
	player = game.Players:GetPlayerFromCharacter(script.Parent.Parent)
	local Animation = Instance.new("Animation")
	Animation.AnimationId = "rbxassetid://12168658961"
	Idle = player.Character.Humanoid:LoadAnimation(Animation)
	Idle:Play()
end)
script.Parent.Unequipped:Connect(function()
	player = game.Players:GetPlayerFromCharacter(script.Parent.Parent)
	Idle:Stop()
	if Sweep then
		Sweep:Stop()
	end
end)
using = false
canfire = true

script.Parent.Activated:Connect(function()
	if canfire == true then
		script.Parent.Handle.Sound:Play()
		canfire = false
		using = true
		local Animation2 = Instance.new("Animation")
		Animation2.AnimationId = "rbxassetid://12168662362"
		Sweep = player.Character.Humanoid:LoadAnimation(Animation2)
		Sweep:Play()
		--function!!!!!!!!!
		wait(.25)
		using = false
		wait(.75)
		canfire = true
	end
end)

script.Parent.Handle.Touched:Connect(function(dust)
	if dust.Name == "dust" and using == true then
		if dust:FindFirstChild("Decal").Transparency < 0.9 then
		dust.Decal.Transparency += 0.1
		player.CleaningXP.Value += math.floor(player.CleaningXPGAIN.Value/17.5)
	elseif dust:FindFirstChild("Decal").Transparency >= 0.9 then
		dust:Destroy()
		player.CleaningXP.Value += player.CleaningXPGAIN.Value+math.random(-25,25)
		end
	end
end)

there are no output errors, and it only works when you move your character side-to-side, why does this happen?

It is either because your broom is either “submerged” into the part it’s sweeping or that your character is anchored. I recommend changing the size of the handle so that it touches the dust when it plays the animation but not all the time.

Wow, overlooked that completely. Thanks!

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