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

Script to display the month doesn't show up on the gui?

Asked by 5 years ago
local GUI = game.StarterGui.Season
local Text = game.StarterGui.Season.SeasonText.Text
local Month = 0
local Day = 0
local Year = 0
local Sea = 0

Text = ('M'..Month)

while true do
    if Month == 12 then
        Month = Month - 11 else
        Month = Month + 1
    end
end

I'm probably any idiot but i'm not sure why this wouldn't work.

0
what script is it? HaveASip 494 — 5y

3 answers

Log in to vote
1
Answered by
HaveASip 494 Moderation Voter
5 years ago
Edited 5 years ago

You have 2 problems in your script. 1. You changed gui what located in starterGui. You need to change playersGui, but here is another problem. You cant access players gui from default script if you turned on filtering. You need to use remote events for it 2. You put "else" on wrong line.

Also I fixed your script. Here is it

For first insert a script in ServerScriptService and type this

local Event = Instance.new("RemoteEvent") --Creating a new event
Event.Parent = game:GetService("ReplicatedStorage")
Event.Name = "TestEvent" --Your event name
local Month = 0
local Day = 0
local Sea = 0

Event:FireAllClients("M"..Month) --Firing to client using event

while true do
    if Month == 12 then
        Month = Month - 11
    else
        Month = Month + 1
    end
end

Now insert localscript into StarterGui and type this...

local Event = game:GetService("ReplicatedStorage"):WaitForChild("TestEvent") --Event what we created using server script
local player = game:GetService("Players").LocalPlayer --Player
local GUI = player.PlayerGui.Season --Player's gui
local Text = GUI.SeasonText.Text --Text in player's gui

Event.OnClientEvent:Connect(function(Message) --Message is fired information from server
    Text = Message
end)

I hope you understand.

0
your setting the text of the GUI in a variable which wouldn't work since your just storing it instead of actually changing it User#23365 30 — 5y
0
Yeah this didn't work. Neon_isHere 100 — 5y
Ad
Log in to vote
0
Answered by 5 years ago

The problem is that you used 'StarterGui', you can't use that to change it use this instead:

local plr = (Put the player that will get the GUI to change here)
local GUI = plr.PlayerGui.Season
local Text = GUI.SeasonText.Text
local Month = 0
local Day = 0
local Year = 0
local Sea = 0

Text = ('M'..Month)

while true do
    if Month == 12 then
        Month = Month - 11 else
        Month = Month + 1
    end
end

the starter GUI is what GUI the player is will get, but if you want to change anything in the GUI that he haves currently, then put the player.PlayerGui.GUINameHere.... and it also should be in a local script

0
He cant access to player gui from script dude. HaveASip 494 — 5y
Log in to vote
0
Answered by 5 years ago

The other answers aren't even going to fix the problem... This will though! (Explanation at the end) try this: |||||||LOCAL SCRIPT||||||||

repeat wait() until game.Players.LocalPlayer
local plr = game.Players.LocalPlayer
local GUI = plr.PlayerGui.Season
local T = GUI.SeasonText
local Month = 0
local Day = 0
local Year = 0
local Sea = 0

T.Text = ('M'..Month)

while wait() do
    if Month == 12 then
        Month = Month - 11 else
        Month = Month + 1
    end
end

What I did:

I made it so you get the players starter gui and not the servers starter gui I Changed the variable with the text to the variable and changed the text later... I put a wait() command in the while loop

And hopefully you put this as a localscript..... In StarterGui...

Things you should know: use player.PlayerGui instead of game.StarterGui put a wait inside the while true do or put while wait() do for no crashes... change the variables text as .Text and not the variable as the text property.

Answer this question