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.
local dialog = script.Parent
dialog.DialogChoiceSelected:connect(function(player, choice)
local stats = player:FindFirstChild("leaderstats")
if not stats then return end
local leaflets = stats:FindFirstChild("Leaflets")
if not leaflets then return end
if choice == script.Parent.DialogChoice.DialogChoiceA.ConfirmA then
if leaflets.Value >= 10 then
leaflets.Value = leaflets.Value - 10
game.ReplicatedStorage.WeaponA:Clone().Parent = player.Backpack
end
elseif choice == script.Parent.DialogChoice.DialogChoiceB.ConfirmB then
if leaflets.Value >= 7 then
leaflets.Value = leaflets.Value - 7
game.ReplicatedStorage.WeaponB:Clone().Parent = player.Backpack
end
elseif choice == script.Parent.DialogChoice.DialogChoiceC.ConfirmC then
if leaflets.Value >= 10 then
leaflets.Value = leaflets.Value - 10
game.ReplicatedStorage.WeaponC:Clone().Parent = player.Backpack
end
elseif choice == script.Parent.DialogChoice.DialogChoiceD.ConfirmD then
if leaflets.Value >= 20 then
leaflets.Value = leaflets.Value - 20
local pet = game.ReplicatedStorage.Pet:Clone()
local playerName = player.Name
local playerCharacter = game.Workspace:FindFirstChild(player.Name)
pet.Torso.CFrame = playerCharacter.Torso.CFrame - Vector3.new(0, 0, 5)
pet.Name = player.Name .. "'s" .. " Clone"
pet.Parent = playerCharacter
pet.Pants.PantsTemplate = playerCharacter.Pants.PantsTemplate
pet.Shirt.ShirtTemplate = playerCharacter.Shirt.ShirtTemplate
end
end
end)

1 comment
Irrelevant, but for playerCharacter I would access it form the player itself, with player.Character.