Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

PlayerGui is not a valid member of DataModel Error?

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

✓ Accepted answer

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

2 comments

0

It worked, thanks!

0

np

This discussion is preserved as it was. New answers, comments, and votes are closed.