So, i’m not sure which one I need to use to do this:
If the first model is cloned then it get spawned in the left conveyor but if the second model gets cloned while the first model is still spawning, then the second clone needs to be spawned in the right conveyor.
Anyone knows which one I need to use? Or do I not need to use both of them?
Here’s the script that im currently using(it doesn’t works yet cause I thought I need to use remote functions or remote events);
local CH = false
local var = game.Workspace:WaitForChild("OldTvClone")
----------------
local var01 = game.Workspace:WaitForChild("TvClone1")
local var02 = game.Workspace:WaitForChild("TvClone2")
print("Var has been created")
if var and var01 then
print(var, var01)
CH = true
local varOldTv = game.ReplicatedStorage.TvMakers.TvMakerLVL1.OldTv.PartsOfOldtv:Clone()
varOldTv.Parent = game.Workspace
for i, v in pairs(varOldTv:GetChildren()) do
v.Anchored = false
v.Transparency = 0
v.CanCollide = false
print("It works")
end
end
Use a remote event if you want to have something done on the server and you don’t need anything returned from the server.
Use a remote function if you want something done on the server but you need something back from the server, like an error message or data only the server can see.
Unless the model clone is initiated by the Client/Player then you shouldn’t need a remote in this instance. If they are clicking on a part to create the Clone, then it will be a normal Script, inside of which you can use a Boolean (true/false) value to say whether the Left Conveyor has just cloned. If true, then you know to Clone on the right Conveyor.
Yes, so when you spawn on the Left conveyor, set the bool to true. Then at the next clone, check the bool value and go left if false, right if true.
You might also want to add a cooldown (not sure how your cloning works) to reset the bool at some point.
The bool needs to be in your server side Script. This is a bool in your script: local CH = false
Just create another one: local LeftConveyorCloned = false
Then set it to true as part of your Clone process
Ok, but I have another script in serverscriptservice but that one clones the original model. And now I created another script in serverscriptservice so that one can handle if the other conveyor already is spawning one. Doesn’t the bool needs to be in the other script that clones the original?
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local tvRequest = Instance.new("RemoteFunction")
tvRequest.Parent = ReplicatedStorage
tvRequest.Name = "CreateOldTvRequest"
local function tvRequestFunction(player)
local Cash = player:WaitForChild("leaderstats"):WaitForChild("Cash")
local leaderstats = player.leaderstats
print(Cash.Value)
if Cash.Value >= 0 then
Cash.Value -= 0 --Subtract 0 from the Player's Cash
local oldtvclone = game.ReplicatedStorage.Tvs.OldTv.PartsOfOldTv:Clone()
oldtvclone.Parent = game.Workspace
oldtvclone.Name = "OldTvClone"
print(oldtvclone)
print(oldtvclone.Parent)
for i, v in pairs(oldtvclone:GetChildren()) do
v.CanCollide = true
v.Transparency = 0
v.Anchored = false
end
else
print("You don't have enough cash")
end
end
tvRequest.OnServerInvoke = tvRequestFunction
local CH = false
local var = game.Workspace:WaitForChild("OldTvClone")
----------------
local var01 = game.Workspace:WaitForChild("TvClone1")
local var02 = game.Workspace:WaitForChild("TvClone2")
print("Var has been created")
if var and var01 then
print(var, var01)
CH = true
local varOldTv = game.ReplicatedStorage.TvMakers.TvMakerLVL1.OldTv.PartsOfOldtv:Clone()
varOldTv.Parent = game.Workspace
for i, v in pairs(varOldTv:GetChildren()) do
v.Anchored = false
v.Transparency = 0
v.CanCollide = false
print("Xd")
end
end
That first error is trying to teleport the user to another game. Have you got any suspicious plugins loaded?
The second repeating error is trying to make purchases.
OK, so it is not really helping you in the script, but have a look please.
With regards to the bool check, it needs to operate like a debounce, which you will see mentioned regularly on the DevForum and in the Roblox Education stuff. It can be used as a means of checking if an event has occured within a certain time period and stopping it from repeating to frequently.