Hello I made a script that works on studio with no errors but doesnt work in-game.
Only the billboard gui clonning thing doesn’t work. Others working with no errors.
local datastoreservice = game:GetService("DataStoreService")
local data1 = datastoreservice:GetDataStore("data5")
local function DataStuff(Player)
local NonUsingItemsFolder = Instance.new("Folder")
NonUsingItemsFolder.Parent = Player
NonUsingItemsFolder.Name = "NonUsingItemsFolder"
local leaderstats = Instance.new("Folder")
leaderstats.Parent = Player
leaderstats.Name = "leaderstats"
local EnabledGive = Instance.new("BoolValue")
EnabledGive.Parent = Player
EnabledGive.Value = false
EnabledGive.Name = "EnabledGive"
local success, errormsg = pcall(function()
local Crush_Points = Instance.new("IntValue",leaderstats)
Crush_Points.Name = "Crush Points"
Crush_Points.Value = data1:GetAsync(Player.UserId.."-Points",Crush_Points.Value) or 0
local Top_Points = Instance.new("IntValue",leaderstats)
Top_Points.Name = "Top Crush Points"
Top_Points.Value = data1:GetAsync(Player.UserId.."-TopPoints",Top_Points.Value) or 0
end)
if success then
print("Successfully got data!")
else
print("Error: " .. errormsg)
Player:Kick("Error getting data.")
end
end
game.Players.PlayerAdded:Connect(function(Player)
-- Crush Points
-- Top Crush Points
DataStuff(Player)
--local chr = Player.Character
print("xd")
local Billboard = game.ReplicatedStorage.Billboard.BillboardGui:Clone()
for i,v in pairs(game.Workspace:GetChildren()) do
print(Player.Name .. v.Name)
if v.Name == Player.Name then
print("clonning.")
Billboard.Parent = v.Head
print("done.")
end
end
while true do
wait(0.1)
Billboard.TextLabel.Text = Player.leaderstats["Crush Points"].Value
end
end)
game.Players.PlayerRemoving:Connect(function(player)
print("Player left.")
local success, err = pcall(function()
data1:SetAsync(player.UserId.."-Points",player.leaderstats["Crush Points"].Value)
data1:SetAsync(player.UserId.."-TopPoints",player.leaderstats["Top Crush Points"].Value)
end)
if success then
print("Successfully saved "..player.Name.."'s Data!")
else
warn(err)
end
end)
while true do
wait(1)
for i,v in pairs(game.Players:GetChildren()) do
if v.EnabledGive.Value == true then
v.leaderstats["Crush Points"].Value += 1
if v.leaderstats["Top Crush Points"].Value <= v.leaderstats["Crush Points"].Value then
v.leaderstats["Top Crush Points"].Value = v.leaderstats["Crush Points"].Value
end
end
end
end