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

Server Script wont find a Gui inside of PlayerGui yet its able to access the Player just fine?

Asked by 6 years ago

So basically if you odnt have enough money for something, some text on screen will tell you that. That Text object is always on screen just its not visible. This script here is supposed to make it visible for a little then back to not visible.

The error is ScrTxt is not a valid member of PlayerGui on line 15

This all works in Studio just not Online. It's a server script inside of an NPC's head.

brick = script.Parent
range = 15 

while true do
        wait()
    plrs = game.Players:GetChildren()
    for i,plr in ipairs(plrs) do
        if plr.Character ~= nil then
            tor = plr.Character.HumanoidRootPart
            if (brick.Position-tor.Position).magnitude <= range then
               if plr.PlayerStats.Dollars.Value >= 500 then
                    plr.PlayerStats.Dollars.Value = plr.PlayerStats.Dollars.Value * 0.70
                    tor.CFrame = CFrame.new(23.35, 3.6, 82.9)
                else
                    plr.PlayerGui.ScrTxt.Note.Text = "Not Enough Money. The Jail took nothing."
                    plr.PlayerGui.ScrTxt.Note.Visible = true
                    tor.CFrame = CFrame.new(23.35, 3.6, 82.9)
                    wait(4)
                    plr.PlayerGui.ScrTxt.Note.Visible = false
                end
            end
        end
    end
end

So I thought maybe a server script in the workspace couldn't access the PlayerGui but it should be able to shouldn't it? Also it has to access the Player to get the "PlayerStats" just a few lines above. Anyone know why its not detecting the Gui? Any help is appreciated.

1
scripts can't access playergui Vulkarin 581 — 6y

1 answer

Log in to vote
2
Answered by 6 years ago

Your monitor, obviously, is connected to your computer. However, your Player object is on the server and got replicated to the client, too. You should look at Remote Events, or do the checks on the client.

Hope this helps!

Ad

Answer this question