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

2 comments
Line 7, you have game.Workspace.Players, it should just be game.Players as Players is a service under DataModel (game).
Thanks!