local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local MarketplaceService = game:GetService("MarketplaceService")
local Argument = ReplicatedStorage.Argument
local TypeWriter = require(ReplicatedStorage.TypeWriter)
local GingerbreadsValue = script.Parent.GingerFrame.Gingerbreads
function Comma(amount)
local formatted = amount
while true do
formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2')
if (k==0) then
break
end
end
return formatted
end
local Player = Players.LocalPlayer
Player.DataFolder.Gingerbreads:GetPropertyChangedSignal("Value"):Connect(function()
TypeWriter.Type(GingerbreadsValue, Comma(Player.DataFolder.Gingerbreads.Value))
end)
Argument.OnClientEvent:Connect(function(Arg)
if not Arg then return end
if Arg == "PlayerJoinChangeValues" then
GingerbreadsValue.Text = TypeWriter.Type(GingerbreadsValue, Comma(Player.DataFolder.Gingerbreads.Value)) -- error line
end
end)
The typewriter is just a cool addon which writes the text (as if you’re writing it on a paper)
like H-E-L-L-O
local TypeWriter = {}
TypeWriter.Type = function(Object, Text)
for i = 1, #Text, 1 do
Object.Text = string.sub(Text, 1, i)
wait(0.005)
end
end
return TypeWriter
Module scripts are often confused on how to use them by many developers, its better to do the script below, as incase of any lag, or slow internet of player, the text might get stuck too, this script runs in client, and this may take upto 50 kb of client memory usage, it does not lag too
Use this local script:
local function typewritier(texttotype,textlabel)
textlabel.Text = "" -- clears textlabel text
for i = 1,#texttotype do -- # means length of something, here it means length of text
task.wait(0.05)
textlabel.Text = textlabel.Text..string.sub(texttotype,i,i)
end
end
-- how to run it
typewritier("Hello, this is a testing message",textlabel) -- first is your string, second is your instance(object) textlabel
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local MarketplaceService = game:GetService("MarketplaceService")
local Argument = ReplicatedStorage.Argument
local TypeWriter = require(ReplicatedStorage.TypeWriter)
local GingerbreadsValue = script.Parent.GingerFrame.Gingerbreads
function Comma(amount)
local formatted = amount
while true do
formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2')
if (k==0) then
break
end
end
return formatted
end
local Player = Players.LocalPlayer
Player.DataFolder.Gingerbreads:GetPropertyChangedSignal("Value"):Connect(function()
TypeWriter.Type(GingerbreadsValue, Comma(Player.DataFolder.Gingerbreads.Value))
end)
Argument.OnClientEvent:Connect(function(Arg)
if not Arg then return end
if Arg == "PlayerJoinChangeValues" then
GingerbreadsValue.Text = tostring(TypeWriter.Type(GingerbreadsValue, Comma(Player.DataFolder.Gingerbreads.Value))) -- error line
end
end)
function intToString(int)
local thingToChange1 = string.reverse(tostring(int))
local thingToChange2 = string.split(thingToChange1,'')
local End = ''
if #thingToChange2 > 3 then
for i,v in ipairs(thingToChange2) do
if i%3 == 0 then
End=End..v..','
else
End=End..v
end
end
else
End = table.concat(thingToChange2)
end
return string.reverse(End)
end