I'm having issue with my mopping server script

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I want it to destroy the clone frame my part makes when you click on the part
  2. What is the issue? Include screenshots / videos if possible!
    I’m having an issue with my mopping server script when I add the part that is supposed to destroy the clone frame it breaks my mopping server script

here’s my moppin server script

local SpillLocationsFolder = game.Workspace.SpillLocations
local SpillLocations = SpillLocationsFolder:GetChildren()

local function DestroyFrame(player)
    local mainFrame = player.PlayerGui:WaitForChild("MainFrame")
    local scrollingFrame = mainFrame:WaitForChild("StartFrame"):WaitForChild("JobsHolder"):WaitForChild("ScrollingFrame")

    for _, frame in pairs(scrollingFrame:GetChildren()) do
        if frame:IsA("Frame") and frame.Name == "Job" and frame.Visible then
            frame:Destroy()
            break
        end
    end
end


for i = 1, #SpillLocations do
    local Spill = SpillLocations[i]
    local MopSpillEvent = Spill.MopSpill

    MopSpillEvent.OnServerEvent:Connect(function(Player)
        print("Cleaning Spill")
        local Tween = TweenService:Create(Spill, TweenInfo.new(5), {Size = Vector3.new(0, 0, 0)})
        Tween:Play()
        wait(5)
        Spill.Transparency = 1
        Player.leaderstats.Points.Value = Player.leaderstats.Points.Value + 1
        DestroyFrame(Player)
    end)
end

while true do
    local RandomSpill = SpillLocations[math.random(1, #SpillLocations)]
    RandomSpill.Transparency = 0
    RandomSpill.BrickColor = BrickColor.Random()
    RandomSpill.Size = Vector3.new(0.1, 4.4, 4.65)
    wait(60)
end

1 Like

how does it break?

it quits mopping the floor in it doesn’t destroy the frame at all

so it doesn’t even finish mopping and then it breaks?

if that’s the case, can you sprinkle a bit of print statements in the .OnServerEvent function to see where the code stops?

maybe the code stops somewhere? not really sure what’s going on

it’s not doing anything it’s not printing anything

so it doesn’t even run??

can i see your client-side code

here you go ```lua

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)

bruh

what if you sprinkle print statements in the client code???

i legit can’t see anything wrong what’s going on today :sob: