So I am making a GUI for my game with rounds that has a GUI that is supposed to change when a variable (gamestatusv) is changed to 1 or 2. 1 is for on and 2 is for off.
local gamestatusv = game.ReplicatedStorage:WaitForChild("GameStatus") ---- Location of IntValue in game. game.gamestatusv.Changed:connect(function() --Function if game.gamestatusv.Value == "1" then game.Players.LocalPlayer.PlayerGui.CoinGuessGui.Backs.Visible = true --On game.Players.LocalPlayer.PlayerGui.CoinGuessGui.Heads.Visible = true game.Players.LocalPlayer.PlayerGui.CoinGuessGui.Tails.Visible = true game.Players.LocalPlayer.PlayerGui.TimerGui.Timer.Visible = true else if gamestatusv.Value == "2" then game.Players.LocalPlayer.PlayerGui.CoinGuessGui.Backs.Visible = false --Off game.Players.LocalPlayer.PlayerGui.CoinGuessGui.Heads.Visible = false game.Players.LocalPlayer.PlayerGui.CoinGuessGui.Tails.Visible = false game.Players.LocalPlayer.PlayerGui.TimerGui.Timer.Visible = false end end end)
I get the error: "gamestatusv is not a valid member of datamodel" . I am confused and really stuck. How do I fix this? I can provide the location of things if you need me to.
Because you're not using 'elseif' but 'else if'
And also, you're getting gamestatusv, and not the instance 'gamestatusv'
So if I am right your script should look something like:
local gamestatusv = game.ReplicatedStorage:WaitForChild("GameStatus") game.gamestatusv.Changed:connect(function() if game.gamestatusv.Value == "1" then game.Players.LocalPlayer.PlayerGui.CoinGuessGui.Backs.Visible = true game.Players.LocalPlayer.PlayerGui.CoinGuessGui.Heads.Visible = true game.Players.LocalPlayer.PlayerGui.CoinGuessGui.Tails.Visible = true game.Players.LocalPlayer.PlayerGui.TimerGui.Timer.Visible = true elseif game.gamestatusv.Value == "2" then -- where you went wrong. game.Players.LocalPlayer.PlayerGui.CoinGuessGui.Backs.Visible = false game.Players.LocalPlayer.PlayerGui.CoinGuessGui.Heads.Visible = false game.Players.LocalPlayer.PlayerGui.CoinGuessGui.Tails.Visible = false game.Players.LocalPlayer.PlayerGui.TimerGui.Timer.Visible = false end end end)
Hope this works!
Line 2 of your script you're calling for game.gamestatusv. So the game is reading that as:
game.game.ReplicatedStorage:WaitForChild("GameStatus").Changed:Connect(function()
Change it to:
gamestatusv.Changed:Connect(function()
This should work.