hi thank u i followed an youtube turtatiol by but it did not work here is the code
print("Hello world!")
print("Hello world!")
local ReplicatedStorage=game:GetService("ReplicatedStorage")
local ServerStorage=game:GetService("ServerStorage")
local remotetext=ReplicatedStorage:WaitForChild("RemoteText")
local remotecounter=ReplicatedStorage:WaitForChild("CounterStart")
local message="Waiting For Players To Join"
local theme={"Robot","Face","Flower","Sword","House","Person","Fire","Book","Phone","Parkour","Enemy","Cloud","Fire","Tree","Car","Computer","Chess","Box","Shoes","Coin","Cup","Watch","Pencil","Bread","Hat","Bottle","Plane","Sunglasses","Zombie","Diamond","Chain","SpongeBob","SuperHero","Evil","Spider","Scary","Bee","Pistol","Water","skelett","Skull","Money","Girl","Happy","Angry","Clown","Smile"}
--local holder = ReplicatedStorage:WaitForChild("itemholder")
local DataStore=game:GetService("DataStoreService"):GetDataStore("DataSafer")
local toolsafer=game:GetService("DataStoreService"):GetDataStore("ToolSafer")
local library=ReplicatedStorage:WaitForChild("Library")
local dir={}
local function edit(player,list)
dir[player.Name]=list
end
local function setup(player,list)
for i=1,#list do
local tool=library:FindFirstChild(list[i])
if tool then
local clone=tool:Clone()
clone.Parent=player.Backpack
else
print(list[i].."not found")
end
end
end
--local ItemDataStore=game:GetService("DataStoreService"):GetDataStore("ItemSafer")
local randomtheme=theme[ math.random( #theme ) ]
function restart(player)
end
local currencyname="Crafts"
game.Players.PlayerAdded:Connect(function(player)
local leaderstatus=Instance.new("Folder")
leaderstatus.Name="leaderstats"
leaderstatus.Parent=player
local cash=Instance.new("IntValue")
cash.Name=currencyname
cash.Parent=leaderstatus
local ID=currencyname.."-"..player.UserId
local saveData=nil
pcall(function()
saveData=DataStore:GetAsync(ID)
end)
if saveData ~= nil then
cash.Value=saveData
else
cash.Value=30
end
local ready=false
player.CharacterAdded:connect(function(char)
local bp=player.Backpack
local data=nil
if ready==false then
ready=true
data=toolsafer:GetAsync(player.UserId)
if data then
setup(player,data)
edit(player,data)
end
end
char.Humanoid.Died:connect(function()
char.Humanoid:UneqipTools()
local old=player.StarterGear:GetChildren()
for i=1,#old do
old[i]:Destroy()
end
local new=player.Backpack:GetChildren()
for i=1,#new do
new[i]:Destroy()
end
end)
local count=0
local function adjust()
if char.Humanoid.Health>0 then
local list={}
local equipped=char:FindFirstChild("Tool")
if equipped then
table.insert(list,equipped.Name)
end
local tools=bp:GetChilddren()
for i=1,#tools do
table.insert(list,tools[i].Name)
end
if count~=list then
edit(player,list)
count=#list
end
end
end
bp.ChildAdded(adjust)
bp.ChildRemoved(adjust)
char.ChildAdded:connect(function(child)
if child.ClassName == "Tool" then
adjust()
end
end)
char.ChildRemoved:connect(function(child)
if child.ClassName=="Tool" then
adjust()
end
end)
end)
message="Game Begins"
remotetext:FireClient(player,message)
wait(1)
message="Game Begins."
remotetext:FireClient(player,message)
wait(1)
message="Game Begins.."
remotetext:FireClient(player,message)
wait(1)
message="Game Begins..."
remotetext:FireClient(player,message)
wait(1)
remotetext:FireClient(player,message)
message="Game Begins.."
wait(1.7)
remotecounter:FireAllClients()
message="Theme: "..randomtheme
remotetext:FireClient(player,message)
end)
game.Players.PlayerRemoving:Connect(function(player)
toolsafer:SetAsync(player.UserId,dir[player.Name])
dir[player.Name]=nil
local ID=currencyname.."-"..player.UserId
DataStore:SetAsync(ID,player.leaderstats[currencyname].Value)
end)
game:BindToClose(function()
-- game is shutting down
for i,player in pairs(game.Players:GetPlayers()) do
if player then
player:Kick("Thank you Your Data Has Been Saved")
end
end
wait(5)
end)
local shopitems=game:GetService("ServerStorage"):WaitForChild("ShopItems")
local givetool=ReplicatedStorage.givetool
local ivefergot=ReplicatedStorage:WaitForChild("ivefergot")
ReplicatedStorage.GetInfo.OnServerInvoke=function(player,item)
return shopitems[item].Crafts.Value
end
ReplicatedStorage.CheckingSale.OnServerInvoke=function(player,item)
print("hhl")
local price=shopitems[item].Crafts.Value
if player.leaderstats.Crafts.Value>=price then
player.leaderstats.Crafts.Value=player.leaderstats.Crafts.Value-price
local gear=shopitems[item][item]:Clone()
gear.Parent=player.StarterGear
local gear=shopitems[item][item]:Clone()
gear.Parent=player.Backpack
return true
else
return false
end
end
--game.Players.PlayerAdded:Connect(function(player)
-- local folder = Instance.New("Folder")
-- folder.Name = player.Name
-- wait(1)
-- folder.Parent = holder
--end)
--ndFirstChild(player.Name)
-- if folder then
-- folder:Destroy()
-- end
--end)for _,player in pairs(game.Players:GetChildren()) do
-- for _,tool in pairs(player.Backpack:GetChildren()) do
-- tool.Parent = ReplicatedStorage:FindFirstChild("itemholder"):FindFirstChild(player.Name) -- This way, the tools wont get mixed up with other players' tools.
-- end
-- end
