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

When I switched to FE, This broke?

Asked by 8 years ago

I decided to switch to FE, so I don't get hacked. Can someone tell me what broke? This is in a server script inside of a text button in the startergui.

local passid = 236050258 -- The ID of the gamepass goes here
local GamePassService = game:GetService('GamePassService')
local player = script.Parent.Parent.Parent.Parent.Parent
--[[
while true do
    wait(1)
    for i,v in pairs(game.ReplicatedStorage.Perkers:GetChildren()) do
    if GamePassService:PlayerHasPass(player, passid) then
        player:FindFirstChild("PlayerGui").WalkSpeedPass.Frame.Visible = true
    elseif player.Name == v.Value then
        player:FindFirstChild("PlayerGui").WalkSpeedPass.Frame.Visible = true
else
    player:FindFirstChild("PlayerGui").WalkSpeedPass.Frame.Visible = false
    script.Disabled = true
        end
    end
end
--]]

function hasGamePass()
    return GamePassService:PlayerHasPass(player, passid)
end

function isPerker()
    for _, perker in pairs(game.ReplicatedStorage.Perkers:GetChildren()) do
        if perker.Value == player.Name then
            return true
        end
    end
    return false
end

local frame = script.Parent.Parent
while true do
    frame.Visible = isPerker() or hasGamePass()
    wait(1)
end

1 answer

Log in to vote
2
Answered by 8 years ago

With FilteringEnabled, the server no longer has access to clients' GUIs. Only LocalScripts can modify GUIs with FilteringEnabled, as LocalScripts run client-side. If you want a GUI to display on the client, you'll have to use RemoteEvents. Here's an example of how you could use a RemoteEvent to make your current method work with FilteringEnabled...

First, create a RemoteEvent in ReplicatedStorage and name it ShowGuiEvent.

Here's a basic example of what you're trying to accomplish:

[Script (in ServerScriptService or equivalent)]

local ShowGuiEvent = game.ReplicatedStorage.ShowGuiEvent

ShowGuiEvent:FireClient(player) -- player should be the player you want to send the message to

[LocalScript (parented to the frame you want to show)]

local ShowGuiEvent = game.ReplicatedStorage.ShowGuiEvent

local frame = script.Parent


ShowGuiEvent.OnClientEvent:connect(function()
    frame.Visible = true
end)

Keep in mind that the RemoteEvent can take up to 2 seconds to be received on the client (though it usually takes less than a second.)

To learn more about RemoteEvents and RemoteFunctions, this wiki page will likely prove invaluable.

Good luck! I hope this helps.

Ad

Answer this question