Spillage System Problem

Hey there! I am trying to create spill system that workers can clean up. The problem is that the spill spawns sideways and then it doesn’t spawn after the wait time.

This is the current code I have:

local Wait_Time = 10
local Spill = script.SpillSample
local SpillZones = game.Workspace.SpillLocations:GetChildren()

local RandomLocation = SpillZones[math.random(1, #SpillZones)]

while task.wait(Wait_Time) do
	local newSpill = Spill:Clone()
	newSpill.BrickColor = BrickColor.random()
	newSpill.Parent = RandomLocation
	newSpill.CFrame = RandomLocation.CFrame
	print("Spawned Spill")
end

Any help will be appreciated!

1 Like

is “SpillSample” a single part or a model

are there any errors in the output
more context would be nice, like screenshots if you can of what happens

Just rotate the spill for it to not be sideways

Also I suggest you use GetPivot and PivotTo instead of setting CFrames

It is a union, there are no errors and it prints “Spawned Spill”

screenshots then

can i see what it looks like

maybe the union orientation is not correct, you can use the surface orientation indicator to see the front face and compare it with the brick where the spill is supposed to spawn

image

It spawns on the side like that, after this one spawns no more spawn after.

can u show the surface orientation indicator (open with right click on part in studio mode)
on both of the parts and send screenshot of that

u could always just do

newSpill.CFrame = RandomLocation.CFrame * CFrame.Angles(math.rad(90),0,0)

try that code to see what happens if it is weird switch to CFrame.Angles(0,math.rad(90),0) etc i dont know what the orientation is

1 Like

The code didn’t work but I think this is what you wanted to see?

image

Yeah, but is it flipped a different way now?

No, it hasn’t flipped at all.

charchar

is the union welded to any object?

can you make a place file so i can see

No it’s not welded to anything.

place file

doesnt need to have anything but the spill system in it for me to fix it

mopping.rbxl (40.9 KB)

k ill take a look

303030303030

theres no spill locations in the place file

mopping.rbxl (42.1 KB)

Apologies.

i fixed it works now

local Wait_Time = 10
local Spill = script.SpillSample
local SpillZones = game.Workspace.SpillLocations:GetChildren()

--[[
local RandomLocation = SpillZones[math.random(1, #SpillZones)] before random location would always be the same
because it was outside of the loop
]]

while task.wait(Wait_Time) do
	local RandomLocation = SpillZones[math.random(1, #SpillZones)] -- moved here
	
	local newSpill = Spill:Clone()
	newSpill.BrickColor = BrickColor.Random()
	newSpill.Parent = RandomLocation.Parent
	newSpill.CFrame = RandomLocation.CFrame * CFrame.Angles(0,0,math.rad(90))
	print("Spawned Spill")
end
1 Like

Thank you, I appreciate it a lot!