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

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