I keep getting the "expGui is not a valid member of PlayerGui" error It is a local script in starterplayerscripts
here is my script
--References
local gButton = game.Workspace.MissionWall.GreenButton.ClickDetector
local rButton = game.Workspace.MissionWall.RedButton.ClickDetector
local valueRef = game.Workspace.Values
--Values
local missionStatus = valueRef.MissionStatus
local expAmount = valueRef.ExpLevel
local expToNextLevel = valueRef.ExpToNextLevel
--Numbers
local numberOfTimesPressed = 0
local numberOfTimesToBePressed = 5
local expReward = 100
--Mission Script
gButton.MouseClick:Connect(function()
missionStatus = true
game.Players.LocalPlayer.PlayerGui.activeMission.missionLabel.Text = 'Press the red button '..numberOfTimesToBePressed..' more times.'
print('pressed')
end)
rButton.MouseClick:Connect(function()
if missionStatus == true then
if numberOfTimesPressed < numberOfTimesToBePressed then
numberOfTimesPressed = numberOfTimesPressed + 1
game.Players.LocalPlayer.PlayerGui.activeMission.missionLabel.Text = 'Press the red button '..numberOfTimesToBePressed - numberOfTimesPressed..' more times.'
print('pressed')
end
if numberOfTimesPressed == 5 then
missionStatus = false
numberOfTimesPressed = 0
numberOfTimesToBePressed = 5
expAmount.Value = expAmount.Value + expReward
print('finished')
game.Players.LocalPlayer.PlayerGui.activeMission.missionLabel.Text = 'Mission finished'
wait(5)
game.Players.LocalPlayer.PlayerGui.activeMission.missionLabel.Text = 'You have no active missions.'
end
end
end)
--Gui Update Script
while true do
if expAmount.Value == expToNextLevel.Value then
expAmount.Value = 0
expToNextLevel.Value = expToNextLevel.Value * 2
elseif expAmount.Value > expToNextLevel.Value then
expAmount.Value = expAmount.Value - expToNextLevel.Value
expToNextLevel.Value = expToNextLevel.Value * 2
end
game.Players.LocalPlayer.PlayerGui.expGui.Bar.Size = UDim2.new((expAmount.Value / expToNextLevel.Value) * 0.314, 0, 0.114, 0)
game.Players.LocalPlayer.PlayerGui.expGui.TextLabel.Text = expAmount.Value..'/'..expToNextLevel.Value
wait(1)
end
