Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How can I make a GUI teleport you for a certain amount leader stats points?

I want to make GUI that will teleport you somewhere if you have certain amount of leader stats

6 comments

0

I am well aware this is not a request website, however I've spent the whole day trying to make a tool shop just to find out that you need to know what remotes are, and I have no experience with remotes

0

I am just taking alternate approach, so I have pt some effort into my work.

0

So I would normally just give you the link to whatever it is you need to read up on. However, understanding the difference between remote events and remote functions is a bit difficult for someone who is new to scripting, so I will try to summarize it as best as possible. Just give me a few minutes to write up an explanation.

0

Please, I don't want to go through hell again learning about remote thingies

0

Then you can't fix your problem.

0

If you don't learn remote events and functions, you will be severely limiting yourself.

1 answer

This is the source of the information I'm explaining: https://developer.roblox.com/en-us/articles/Remote-Functions-and-Events

So remote functions and remote events are both very similar. They offer a bridge for data to be sent either from the client to the server, server to client, or in some cases, client to server to client/server to client to server.

To understand which one you need to use, you need to know if you want to return anything after sending data over. Let's say you only want the server to run a function and you don't want anything back from the server. In that case you would use a remote event, but if you want to have the server run a function and then you want the server to let the client know that it is done, you would use a remote function.

One thing I need to say before I get into some examples is that in order for the server and client to communicate, the remote event or function has to be stored in "ReplicatedStorage".

Remote Events:

Client to Server

client:

local RE = game.ReplicatedStorage.RemoteEvent

RE:FireServer("a string")

server:

local RE = game.ReplicatedStorage.RemoteEvent

RE.OnServerEvent:Connect(function(player,str)
	print(str)
end)

This prints a string on the server.

Server to Client

client:

local RE = game.ReplicatedStorage.RemoteEvent

RE.OnClientEvent:Connect(function(str)
	print(str)
end)

server:

local RE = game.ReplicatedStorage.RemoteEvent
local player = game.Players.SteamG0D --using myself as an example of a player
RE:FireClient(player, "a string")
--or fire all clients:
RE:FireAllClients("a string")--useful for putting a message in chat for everyone

This prints a string on the client.

Remote Functions:

Client to Server

client:

local RF = game.ReplicatedStorage.RemoteFunction

local str = RF:InvokeServer()
print(str)

server:

local RF = game.ReplicatedStorage.RemoteFunction

RF.OnServerInvoke = function()
	return "a string"
end)

Fetches a string from the server and prints it on the client.

I left out a server to client for remote functions because you should never do that. If you want to do server to client, try to do remote events instead.

So all of the examples above print "a string", the only difference between them is where it is being printed: on the server or on the client.

This discussion is preserved as it was. New answers, comments, and votes are closed.