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

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.

Did you read my script? Is there anything that should not be like that so it can work perfectly how I want it to be?

VIRUS
I’ve just launched the game again and can see the same purchase prompts coming up and also the teleport error. Somewhere in your game, there will be some require() statements which have been injected that are causing these. They detect when you are running the game in Studio so you aren’t aware of them.
Example:
image

You can fix this by removing all plugins and then use another plugin (yeah I know) to remove the injected code. Options such as GameGuard Anti Virus.

REMOTES
Back to the original question (forgive me if I over simplify this). So it looks like in game, I go to the PC and say what I want to make. The GUI is local to the Player, so this is all LocalScript but it needs to fire an event to the server to Purchase what the player wants. You are right that you will need a RemoteEvent or a RemoteFunction to do this.

This page explains what they are, what they do and how to do it:

A RemoteEvent tells the server to do something, but does not expect a response back from it. A RemoteFunction tells the server to do something and can expect a response back, like a confirmation that a purchase was successful. A RemoteEvent should do what you need here, to handle the Gui requests.

CONVEYOR 1 or 2
I see the TV creation works OK. If you show the full code for the server Script that creates your TVs, I can see how you need to add the check whether Conveyor 1 or Conveyor 2.

1 Like

Here’s the complete script that clones the tv; idk if you wanted this script but…

And uhm, that gamepass you have in your screen shot is not mines!? Is that script still in my game?

Cause when I launch the game with my alt account it doesn’t appears.

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
		local CH = false
	else
		print("You don't have enough cash")
	end
end

tvRequest.OnServerInvoke = tvRequestFunction

Yeah, that gamepass is prompted from within your game, along with a few others. It also still tries to teleport, but you must have the permission to allow teleport to another game turned off thankfully. The script probably checks to see if it is the owner of the game playing. Ask a friend to play the game and watch what happens.

1 Like