I am new to scripting so please don’t flame me (like discord servers do). I also tried to follow a tutorial for some idea but it did not work out. I am trying to make a moping system for fun as I am learning still. I am wondering how I can make it so my “mess” can go to certain places and you can mop them up.
My Issue is that I cant figure out how to make a it go to different places more then once… Some videos/Screenshot of what’s happening. Its
I’ve asked some discord servers (got flamed for my code) and I couldn’t find anything or I just did not try hard enough to look.
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
If you need code of the mop or anything I can give it. “mess” script is serverScipt in the “mess” (which is a union because the mop can change the transparency)
local folder = script.Parent.Parent
local mess = folder.Mess
local pos1 = folder.MessPos1
local pos2 = folder.MessPos2
local pos3 = folder.MessPos3
local pos4 = folder.MessPos4
local pos5 = folder.MessPos5
local num = math.random(1,5)
function setPos1()
mess.Position = pos1.Position
end
function setPos2()
mess.Position = pos2.Position
end
function setPos3()
mess.Position = pos3.Position
end
function setPos4()
mess.Position = pos4.Position
end
function setPos5()
mess.Position = pos5.Position
end
while wait() do
local num = math.random(1,5)
if mess.Transparency ~= 1 then
setPos1()
elseif num == 1 then
print("2")
setPos1()
mess.Transparency = 0
elseif num == 2 then
print("3")
setPos2()
mess.Transparency = 0
elseif num == 3 then
print("4")
setPos3()
mess.Transparency = 0
elseif num == 4 then
print("5")
setPos4()
mess.Transparency = 0
elseif num == 5 then
print("6")
setPos5()
mess.Transparency = 0
end
end
Once I can get it to work I will try to find a way to make shorter
ok i really don’t want to flame you rn but the script is really messed up, here are some suggestions to fix this thing; make all the pos variables a dictionary, which is like a set of values in 1 variable that use a string key to access, for example the dictionary {Poop = "Poop"} has the first Poop to identify it as the key, and the second value to identify as the value. also presumably from the values of the position variables youre using Vector3Values or something else, just throw all of those out the window and make a dictionary with the mess positions. now with the absolute horrid mess of convoluted functions, make it a singular function with 1 parameter for a position, so something like setPos(pos) and the code for it would be mess.Position = pos, make ssure that pos is a Vector3. now this if thing over here, just remove it and YOURE DECLARING A VARIABLE TWO TIMES!!! remove the other num variable and then just do
srry too long part 2 setPos(<insert position dictionary name here>.<insert key name here>). also to make a part move to certain locations just set the position property to a different Vector3
Hey, I looked over your code and decided to just rewrite it, here’s the working code, it does not have tool functionality built in but it gets the job done, In this version I made it so it spawns in a random place within a random set area instead of set locations and it also has a little transparency fade when you clean it up.
local mess_spawn = workspace.Mess_Spawn
local mess = game:GetService('ReplicatedStorage').Mess
function Spawn_Mess()
local mess_x = math.random(mess_spawn.Position.X - (mess_spawn.Size.X / 2), mess_spawn.Position.X + (mess_spawn.Size.X / 2))
local mess_z = math.random(mess_spawn.Position.Z - (mess_spawn.Size.Z / 2), mess_spawn.Position.Z + (mess_spawn.Size.Z / 2))
local new_mess = mess:Clone()
new_mess.Parent = workspace.Messes
new_mess.Position = Vector3.new(mess_x, mess_spawn.Position.Y, mess_z)
--// Detect mess cleanup
new_mess.ProximityPrompt.Triggered:Connect(function(player)
game:GetService('TweenService'):Create(new_mess, TweenInfo.new(0.5, Enum.EasingStyle.Quint, Enum.EasingDirection.Out), {Transparency = 1}):Play()
new_mess.ProximityPrompt:Destroy()
task.wait(0.5)
new_mess:Destroy()
end)
end
while task.wait(5) do
Spawn_Mess()
end
Absolutely, All you have to do is put the spawn areas for the messes in a folder, and in the spawn function when it sets the messes parent make it choose a random area from the children of the areas folder, and the wrest would work.