You can write your topic however you want, but you need to answer these questions:
- What do you want to achieve? Keep it simple and clear!
I want to have it where it will destroy my frame that it clones - What is the issue? Include screenshots / videos if possible!
So I made a mopping system where it will mop a spill, then what it’s supposed to do is destroy the frame I clone by clicking a part
my mopping system server script
local TweenService = game:GetService("TweenService")
local SpillFolder = workspace:WaitForChild("SpillLocations")
local function DestroyFrame(player)
local playerGui = player:FindFirstChild("PlayerGui")
local mainFrame = playerGui:FindFirstChild("MainFrame")
local jobFrame = mainFrame:FindFirstChild("job")
jobFrame:Destroy()
end
-- Set up all existing spills
for _, spill in ipairs(SpillFolder:GetChildren()) do
local evt = spill:FindFirstChild("MopSpill")
if evt then
evt.OnServerEvent:Connect(function(player)
print("⏳ Player", player.Name, "begins mopping spill at", spill.Position)
spill.Anchored = false
local tween = TweenService:Create(spill, TweenInfo.new(5), { Size = Vector3.new(0,0,0) })
tween:Play()
tween.Completed:Connect(function()
if spill and spill.Parent then
player.leaderstats.Points.Value += 1
spill:Destroy()
print("✅ Spill cleaned. Awarded 1 point to", player.Name)
DestroyFrame(player)
end
end)
end)
else
warn("No MopSpill RemoteEvent under spill:", spill:GetFullName())
end
end
-- Continuously spawn new spills every minute
spawn(function()
while true do
local spills = SpillFolder:GetChildren()
if #spills > 0 then
local s = spills[math.random(#spills)]
s.Transparency = 0
s.BrickColor = BrickColor.Random()
s.Size = Vector3.new(0.1, 4.4, 4.65)
print("🩸 New spill spawned at", s.Position)
end
wait(60)
end
end)
my mopping system client script
local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
local UserInputService = game:GetService("UserInputService")
local MopAnimation = script.Parent.MopAnimation
local Equipped = false
local Mopping = false
local function isTargetASpill(Spill)
return Spill.Parent == game.Workspace.SpillLocations
end
script.Parent.Equipped:Connect(function()
Equipped = true
end)
script.Parent.Unequipped:Connect(function()
Equipped = false
end)
UserInputService.InputBegan:Connect(function(Input)
if Input.UserInputType == Enum.UserInputType.Keyboard then
if Input.KeyCode == Enum.KeyCode.E and Equipped and not Mopping and Mouse.Target and isTargetASpill(Mouse.Target) then
print("Pressed E while the tool was equipped")
local Target = Mouse.Target
if Target:FindFirstChild("MopSpill") then
Target.MopSpill:FireServer()
local MopAnimationTrack = Player.Character.Humanoid:LoadAnimation(MopAnimation)
MopAnimationTrack.Looped = true
MopAnimationTrack:Play()
Mopping = true
wait(5)
MopAnimationTrack:Stop()
Mopping = false
print(Target.Name)
else
print("No MopSpill event found in target")
end
end
end
end)