Good day,
I created a script that moves a model to a specific position, and the part that receives the model changes folder (to distinguish part with something on it, and others not).
I would like to know how to detect when something is not on the part, to bring back the part to his original folder?
Thank you
local palPart = script.Parent local db = true local light = workspace.ReceivingPallet.GreenLight local Model = workspace.pal12 local cpos = Model.PrimaryPart.Position palPart.Touched:Connect(function(hit) local palToClone = workspace.pal12 local palStorage = game.Workspace.emptyStorageLocation:GetChildren() local numOfStorage = #palStorage if db and palToClone then db = false local ss = game:GetService("ServerStorage") local pal = ss:WaitForChild("pal12") local randPalStorage = math.floor(math.random(1, numOfStorage)) local palClone = pal palClone:Clone() palClone.Parent = workspace Model:SetPrimaryPartCFrame(palStorage[randPalStorage].CFrame + Vector3.new(0,0,0)) Model.Parent = workspace.storagePallet end end)
I think the MoveTo() function could help you a bit. Example:
local Services = setmetatable({}, {__index=function(self, index)return game:GetService(index) end}) Model:MoveTo(Services.Players.LocalPlayer.Character.HumanoidRootPart.Position)