Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to I send this string through FilteringEnabled?

Asked by 6 years ago

I've been spending the past few hours learning about FilteringEnabled, and how I can use it in my shop script. In my script I want a robloxian mannequin in workspace to send information to my GUI, so I have set up a RemoteEvent in that mannequin. Please tell me why this isn't working.

Output: "Unable to cast value to Object"

local ShirtID = (string.sub(script.Parent.Parent.Body.Shirt.ShirtTemplate, 14))


script.Parent.ClickDetector.MouseClick:connect(function()

    script.Parent:WaitForChild("RemoteEvent"):FireClient(ShirtID)

end)


0
That's not how you use RemoteEvents nor how Filtering Enabled works. Try reading it again. iDarkGames 483 — 6y
0
could I at least get more of understanding on what I did wrong? "Try reading it again" isn't very helpful when you have looked over tutorials on the subject for the past few hours. BronzedMocha 60 — 6y
0
I'm not 100%, but don't you need to give the remote the actual player as well? TheeDeathCaster 2368 — 6y

2 answers

Log in to vote
0
Answered by
Aresko 53
6 years ago

It looks like you are trying to send your variable where you should be referencing a player,

local ShirtID = (string.sub(script.Parent.Parent.Body.Shirt.ShirtTemplate, 14))


script.Parent.ClickDetector.MouseClick:connect(function(player)

    script.Parent:WaitForChild("RemoteEvent"):FireClient(player, ShirtID)

end)

Also this might help you some more.

Ad
Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

A simple example of how Filtering Enabled works is as follows:

In the case of doing a Client > Server connection you are obligated to use a remote event or function.

The difference between these two?

  • Remote Events: They don't yield the script and wait for a response when they're called just like a normal event.

  • Remote Functions: They basically do the same, but with the difference of returning the results of the action done by it. So it callbacks, it needs to return something, it waits , expects to return information.

Having Remotes clarified in a simple way, the next question appears .... Where do I store them? Most of the people actually use ServerScriptService or ReplicatedStorage. Take care that both containers have their differences and it is important to remark them.

  • ServerScriptService: This container can only be seen by the server, the client cannot see anything inside of this container.

  • ReplicatedStorage: This container can be seen by both server & client as it replicates to both of them.

Going back to the Client > Server connection and having both important components, where to hold it and how to establish the connection we have now clear on what we can use, which in this case is:

  • Remote Events:

  • :FireServer() method. on the LocalScript.

  • .OnServerEvent() event to actually establish the connection between Server & Client through the remote.

LocalScript

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local exampleEvent = ReplicatedStorage:WaitForChild("exampleEvent")

exampleEvent:FireServer("PrintThis")

ServerScript

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local exampleEvent = Instance.new("RemoteEvent", ReplicatedStorage)
exampleEvent.Name = "exampleEvent"

exampleEvent.OnServerEvent:Connect(function(player, key)
    if key == "PrintThis" then
        print("The example Event listened & printed this from the server");
    end
end)

You might be a bit confused, bare with me.

The LocalScript sends information to the server through the :FireServer() method. In a Client > Server connection the first argument sent to the .OnServerEvent() event is the player, that's why in the moment of the creation of the event in the server script you have "player" as the first argument of the function.

You can send any type of information to the server, remember there is always limitations to what you can send to the server.

  • The most typical example of not being able to send something from the client to the server is an Instance or an Object, it will end up on an error.

Going back to the ServerScript , to establish the connection with the client and be able to get the information sent by the :FireServer() methodwe use the .OnServerEvent() event as previously mentioned. That event will make possible the connection between Client > Server through a secure way.

As long as you understand this conceptuation you will also be able to understand the inverse, Server > Clientconnection and also RemoteFunctions and their different way of nomenclature.

I didn't include the RemoteFunctions & Server > Client because the answer will be too large, I'm leaving you some refference links so you can be a bit autodidact.

Remotes links

Holder links

Hope this helped you , if you have any questions feel free to ask or comment!

Answer this question