I’m trying to make a delivery system that awards players cash when they deliver the box but I’m having trouble cloning the box after players deliver their box, how would I do this?
Thanks, but after awhile the original box is removed from the workspace and the game says “Box is not a valid member of workspace” how do I stop this from happening?
Have a box in ServerStorage or ReplicatedStorage that never gets removed to clone from instead.
EDIT: so you would clone from the box in ServerStorage instead of the one in workspace
Can you explain this better? Are you trying to get a NEW box? If you’re trying to make a part of a script not error out, you could do
local sucess, ErrorMsg = pcall(function()
–whatever
end)
sucess is true if the script has run without any problems, and errormsg is the error message, if there is one. then you can do
if not sucess and ErrorMsg then print(ErrorMsg) --or warn() end)
I want the box to spawn again after a while so players can deliver it again
Ok, If you didn’t know this, if you refer to a variable well, look:
local box = game.Workspace.Box
right?
ok. If that box get’s deleted, this box argument will be NIL. It won’t try to find another box.
That object does not exist anymore.
You might wanna have different names for those boxes;
or set the variable again. Check if it’s nil
so
if box == nil then
box = game.Workspace.Box
end
Trying to do what I said was wrong, it’s basically trying to do
local value = workspace.IntValue.Value
this variable would only be the object that it was when it got checked for it. And you coudn’t do
value = value + 1, that woudnt change the iNTVALUE.VALUE that would replace the variable with +1 added
Do you want to see my clone script?
If you’re okay with it alright.
Here it is
local original = game.ReplicatedStorage.Box
local copy = original:Clone()
copy.Parent = original.Parent
copy:SetPrimaryPartCFrame(CFrame.new(51.432, 1.2, -3.084))
wait(5)
print(“Box Duped”)
the Box is in replicated storage
It prints the box has been duped but no box appears
first of all, if replicated storage it’s always it’s location, then don’t do ORIGINAL.PARENT. do game.ReplicatedStorage.
does the original get removed after some time?
edit 1: nvm i thought about something else
I want it to appear in the workspace
then you need to say clone.Parent = workspace
since the original one IT’S NOT on workspace.
So really, it’s just creating a clone inside of replicated storage.
Oh… lol it worked, Thanks for the help Mr. Programmer
Thanks, I’m a beginner
If you need any help message me
Will do, thanks again for the help.