I'm a player on ROBLOX who wishes to make a game and have just started on ROBLOX Lua Scripting. I'm not experienced at all and need help.
So I want to make a script that makes the text of TextLabel "TransferRateDisplay" (Path : game.StarterGui.ScreenGui.BottomRightGUI.TransferRateDisplay) to change for all players (to the same value for every player too) in the server after the TimeOfDay reaches midnight for each day.
I've put this script inside the StarterPlayerScripts :
function changeCurrency(a, b, c) print("Changing Transfer Rate") print(a) print(b) print(c) local TR = game.Workspace.TransferRate.Value local TRGui = game.Workspace.Players.LocalPlayer.PlayerGui.ScreenGui.BottomRightGUI.TransferRateDisplay local PlusMinus local Multiplier if (b < 5) then Multiplier = 3 end if (b >= 5 or b < 25) then Multiplier = 2 end if (b >= 25) then Multiplier = 1 end if (c == 1) then PlusMinus = 1 end if (c == 2) then PlusMinus = -1 end if (a < 70) then TR = TR + (Multiplier * PlusMinus) if (TR < 8) then TR = 8 end if (TR > 25) then TR = 25 end TRGui.Text = "Transfer Rate : " .. TR .. "Tx / R$" else --Nothing Happens! end end while true do game.Lighting:SetMinutesAfterMidnight(game.Lighting:GetMinutesAfterMidnight() + 2.4) wait(0.1) if (game.Lighting:GetMinutesAfterMidnight() < 1 or game.Lighting:GetMinutesAfterMidnight() > 1439) then math.randomseed(tick()) local a = math.random(1,100) local b = math.random(1,100) local c = math.random(1,2) changeCurrency(a, b, c) end end
So I started a local server of one player in my ROBLOX Studio.
The output in my server view was :
13:34:54.928 - Started network server on XXXXXXXX 13:34:54.929 - Started network server on XXXXXXXX Loaded gloo library. Type _G.gloo.Help() for help. Loaded CmdUtl plugin (v5.0.0) 13:34:55.258 - Successfully opened file - C:/Users/User/AppData/Local/Roblox/server.rbxl 13:35:01.463 - New connection from XXXXXXXX 13:35:01.531 - Replication: Can't create default object of type Players Player -1 added
The output in my player view was :
Loaded gloo library. Type _G.gloo.Help() for help. Loaded CmdUtl plugin (v5.0.0) 13:35:01.460 - ! Joining game '' place 0 at localhost 13:35:01.461 - Connecting to localhost:XXXXXXXX 13:35:02.300 - Connection accepted from XXXXXXXX Changing Transfer Rate 19 2 1 13:36:09.846 - Players is not a valid member of Workspace 13:36:09.847 - Script 'Players.Player1.PlayerScripts.LocalScript', Line 7 - global changeCurrency 13:36:09.847 - Script 'Players.Player1.PlayerScripts.LocalScript', Line 47 13:36:09.847 - Stack End
To do that you would do,
for i,v in pairs(game.Players:GetPlayers()) do v.PlayerGui.ScreenGui.TextLabel.Text = "Text here" end
Also change the names of the ScreenGui and TextLabel
The error doesn't lie! You do realize that "Players" isn't actually in workspace, right? So you dogame.Players.LocalPlayer
, not game.Workspace.Players.LocalPlayer
! If you don't agree, open explorer and see if you have a model called Players in it.
-- Hope I helped.
--PUB1