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

PlayerGui is not a valid member of DataModel Error?

Asked by 3 years ago

I am having an error at line 1(serverscript): PlayerGui is not a valid member of DataModel.

What I want from the following code is: When a timer hits 0 a GUIis displayed with the winning team.

ServerScript Code:

local policeWinGui = game.PlayerGui.PoliceWinTheGame:WaitForChild("TextLabel")

game.ReplicatedStorage.winnerEvent.OnServerEvent:Connect(function()
    policeWinGui.Visible = true
end)

Here is the local script:

script.Parent.Text = seconds.Value

for i=1, seconds.Value do
    wait(1)
    --decrement by 1
    seconds.Value -= 1
    --Update label
    script.Parent.Text= seconds.Value
    --If time is over
    if seconds.Value <= 0 then
        if not _G.carStollen then
            print("Police Win")
            game.ReplicatedStorage.winnerEvent:FireServer()
        elseif _G.carStollen then
            thivesWinGui.Visible = true
            print("Thives Win")
        end
    end
end

1 answer

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

game has no 'playergui' property, players have


game.ReplicatedStorage.winnerEvent.OnServerEvent:Connect(function(player) player.PlayerGui.PoliceWinTheGame.policeWinGui.Visible = true end)

have a good day! - and no don't worry. its morning and we are humans

0
It worked, thanks! badcraftyt 21 — 3y
0
np TheEagle722 170 — 3y
Ad

Answer this question