What do I need to use remote event or remote function?

Hello,

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

This script is inside serverscriptservice incase you wanted to know.

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.

1 Like

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.

So I can better use bool values and if the bool value = true then it need to spawn in the other conveyor right?

Ok, but from my script based then I dont need an remote function right?

And where does the bool value needs to be in? In the model that gets cloned?

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.

1 Like

I already thought about that cause the player can clone the first model multiple times.

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?

Keep it all in your one script that controls the cloning process

Alright so it has to be like this?;

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


I tried this but that doesn’t works either.

I just jumped in to your game “Tv Factory [BEOVISION UPDATE]” to understand what you are trying to do.
The errors in the dev console are worrying:


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.

I do have a few plugins should I delete them?

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.

One mistake tho I haven’t updated this game yet ima update this now and well see what happens.

Copies of popular Plugins and Models with dodgy scripts in them are the most common cause of those types of messages.

I just joined the game and I can’t see any errors anymore. And I uninstalled all the plugins.