I need help making a cleaning system

I have a restaurant, and I want to make a cleaning system where every so often, a spill shows up on the floor, and the player can walk up, click on it, and it disappears. How could I go about this?

I’m not asking anyone to make a full script, I just someone to tell me what concepts I should use and/or where to start. If you wanted to make a full script, that would be greatly appreciated.

Just make few invisible points where you want your junk (spilled stuff) want to be.
Add a loop of 60 seconds so the junk will spawn each minute Use math.random to get random invisible point and clone your spilled/junk part to that random invisible point.

Use ClickDetector and use ClickDetector.MouseClick on that spilled/junk part whenever that click detector is triggered, delete that spilled part by using Instance:Remove() or Instance:Destroy().

4 Likes

Here is a very basic example of how to make such system -

You can have a folder containing stains to clean up
image

You can have with it, a mop -

Client-

local stains = game.Workspace.Stains
local tool = script.Parent
local player = game.Players.LocalPlayer
local Mouse =player:GetMouse()
local rs = game:GetService("ReplicatedStorage")

tool.Activated:Connect(function()
	local goal = Mouse.Target
	
	print(goal)
	
	if stains:FindFirstChild( Mouse.Target.Name) then
		rs:WaitForChild("Cleaning"):FireServer(goal)
	end
end)

Server–

game.Players.PlayerAdded:Connect(function(plr)
	local ls = Instance.new("Folder")
	ls.Parent = plr
	ls.Name = "leaderstats"
	
	local cash = Instance.new("IntValue")
	cash.Name = "Cash"
	cash.Parent = ls
end)


local TweenService = game:GetService("TweenService")
local TweewnInfo = TweenInfo.new(0.5,Enum.EasingStyle.Linear)

game.ReplicatedStorage.Cleaning.OnServerEvent:Connect(function(plr,stain)
	local Tween = TweenService:Create(game.Workspace.Stains:FindFirstChild(stain.Name),TweewnInfo,{Transparency = 1})  
	Tween:Play()
	
	Tween.Completed:Wait()
	plr.leaderstats.Cash.Value +=5
end)
1 Like

Model -
https://www.roblox.com/library/9520851241/Simple-cleaning