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

What about this function does FilteringEnabled not like?

Asked by
Klamman 220 Moderation Voter
9 years ago

I'm having a lot of trouble figuring out how FilteringEnabled works. I've been scripting for a few months now with previous failed attempts (this is the farthest I've gotten, yes!), and this is the most confusing concept I've stumbled upon yet. I get the whole client-server model thing (or maybe not), but what I don't get is why this script won't work. What is it accessing from the client, exactly, that disallows its success? If someone could shed some light on how all of this works, that would be great. Sorry for asking for so much. Cheers.

01local dialog = script.Parent
02dialog.DialogChoiceSelected:connect(function(player, choice)
03    local stats = player:FindFirstChild("leaderstats")
04    if not stats then return end
05 
06    local leaflets = stats:FindFirstChild("Leaflets")
07    if not leaflets then return end
08 
09    if choice == script.Parent.DialogChoice.DialogChoiceA.ConfirmA then
10        if leaflets.Value >= 10 then
11            leaflets.Value = leaflets.Value - 10
12            game.ReplicatedStorage.WeaponA:Clone().Parent = player.Backpack
13        end
14    elseif choice == script.Parent.DialogChoice.DialogChoiceB.ConfirmB then
15        if leaflets.Value >= 7 then
View all 37 lines...
0
Irrelevant, but for **playerCharacter** I would access it form the player itself, with player.Character. PowerHotmail123 90 — 9y

2 answers

Log in to vote
4
Answered by 9 years ago

I am guessing the same logic of a ClickDetector applies with dialogs.

A ClickDetector works with a client interacting with it; filtering doesn't like that. In order to make it work in filtering, you would need to have a RemoteEvent, LocalScript and a ServerScript.

Firstly, you would want to register the interaction with the ClickDetector by using the LocalScript. Remember, the client can see everything the server sees, but cannot change it. Whenever for example, the .MouseClick() event is fired, send it over to the server using a RemoteEvent, then do whatever you need to do within the ServerScript. And if you need to access the player, fear not, as .OnServerEvent returns player as its first argument.

Try applying the same logic/algorithm with dialogs.

Ad
Log in to vote
0
Answered by 9 years ago

When using FilteringEnabled, in order to access the client from server, or server from client, you need to use RemoteEvents/RemoteFunctions, or BindableFunctions/BindableEvents. In this script, you are trying to access the Player's backpack directly, and other player-objects.

What I would do is use RemoteFunctions to call the client(s), and use it to return whatever value you want from it. Hope this helps. :)

Answer this question