ok
server script:
local plrs = game:GetService("Players")
local server = game:GetService("ServerScriptService")
local rStore = game:GetService("ReplicatedStorage")
local sStore = game:GetService("ServerStorage")
local rServ = game:GetService("RunService")
local dataServ = game:GetService("DataStoreService")
local stuff = rStore:WaitForChild("Stuff")
local parts = stuff:WaitForChild("Parts")
local packs = stuff:WaitForChild("Packs")
local gameSave = dataServ:GetDataStore("gameSave")
local saveData = {}
local event = rStore:WaitForChild("Events")
local servEvent = server:WaitForChild("ServCommunication")
local inventories = sStore:WaitForChild("Inventories")
local scripts = sStore:WaitForChild("Scripts")
local idSystem = require(rStore:WaitForChild("IDSystem"))
local itemTabl = idSystem.itemTabl
local function save(plr)
local sucess
local errorMsg
local attempts = 0
local items = 0
local inventory = inventories:WaitForChild(plr.Name)
local packID = inventory:WaitForChild("packId").Value
saveData[plr.UserId].inventory = {}
saveData[plr.UserId].hotbar = {}
saveData[plr.UserId].pack = packID
for i,child in pairs(inventories:FindFirstChild(plr.Name):GetChildren()) do
items += 1
local id = child:FindFirstChild("ID")
if id then
table.insert(saveData[plr.UserId].inventory, id.Value)
end
end
for i,child in pairs(inventories:FindFirstChild(plr.Name).hotbar:GetChildren()) do
local id = child:FindFirstChild("ID")
if id then
table.insert(saveData[plr.UserId].hotbar, id.Value)
end
end
saveData[plr.UserId].taps = plr.leaderstats.Thingies.Value
saveData[plr.UserId].cash = plr.leaderstats.Wealth.Value
repeat
sucess, errorMsg = pcall(function()
gameSave:SetAsync(plr.UserId, saveData[plr.UserId])
end)
attempts += 1
if not sucess then
warn("somethin went wrong with".. plr.Name.. "'s data")
task.wait(3)
end
until sucess or attempts >=10
if sucess then
print(plr.Name.."'s data sucessfuly saved")
else
warn(plr.Name.."'s data couldn't save")
end
local complete = true
return complete
end
plrs.PlayerAdded:Connect(function(plr)
local charLoaded = false
plr.CharacterAdded:Connect(function(char)
charLoaded = true
--Motor6Ds
local toolAt = Instance.new("Motor6D")
toolAt.Name = "ToolAttach"
toolAt.Parent = char:WaitForChild("Right Arm")
toolAt.Part0 = char:WaitForChild("Right Arm")
end)
repeat
task.wait(0.05)
until charLoaded
--Leaderstats
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = plr
local taps = Instance.new("IntValue")
taps.Name = "Thingies"
taps.Parent = leaderstats
local cash = Instance.new("IntValue")
cash.Name = "Wealth"
cash.Parent = leaderstats
--inventories
local inventory = Instance.new("Folder")
inventory.Name = plr.Name
inventory.Parent = inventories
local hotbar = Instance.new("Folder")
hotbar.Name = "hotbar"
hotbar.Parent = inventory
local packID = Instance.new("IntValue")
packID.Name = "packId"
packID.Parent = inventory
--Player Save
local sucess
local plrData
local attempts = 0
repeat
sucess, plrData = pcall(function()
return gameSave:GetAsync(plr.UserId)
end)
attempts += 1
if not sucess then
warn("somethin went wrong with".. plr.Name.. "'s data")
task.wait(3)
end
until sucess or attempts >= 10
if sucess then
if not plrData then
print("assigned default data for".. plr.Name)
saveData[plr.UserId] = {
["taps"] = 0,
["cash"] = 0,
["rebirth"] = 0,
["inventory"] = {1,20},
["hotbar"] = {1,},
["pack"] = 20,
}
else
saveData[plr.UserId] = plrData
saveData[plr.UserId].taps = saveData[plr.UserId].taps or 0
saveData[plr.UserId].cash = saveData[plr.UserId].cash or 0
saveData[plr.UserId].rebirth = saveData[plr.UserId].rebirth or 0
saveData[plr.UserId].inventory = saveData[plr.UserId].inventory or {1,}
saveData[plr.UserId].hotbar = saveData[plr.UserId].hotbar or {1,}
saveData[plr.UserId].pack = saveData[plr.UserId].pack or 20
end
else
warn(plr.Name.."'s data store is not connected")
plr:Kick("Rejoin, your data didn't load")
end
packID.Value = saveData[plr.UserId].pack
taps.Value = saveData[plr.UserId].taps
cash.Value = saveData[plr.UserId].cash
for i,id in pairs(saveData[plr.UserId].inventory) do
if itemTabl[id].itemType == "part" then
local tool = parts:FindFirstChild(itemTabl[id].name):Clone()
tool.Parent = inventory
end
if itemTabl[id].itemType == "pack" then
local pack = packs:FindFirstChild(itemTabl[id].name):Clone()
pack.Parent = inventory
end
end
for i,id in pairs(saveData[plr.UserId].hotbar) do
if itemTabl[id].itemType == "part" then
local tool = parts:FindFirstChild(itemTabl[id].name):Clone()
local toolReplica = parts:FindFirstChild(itemTabl[id].name):Clone()
local toolScript = scripts.PartScript:Clone()
local toolLocal = scripts.PartAnimations:Clone()
toolScript.Parent = tool
toolLocal.Parent = tool
toolScript.Enabled = true
toolLocal.Enabled = true
tool.Parent = plr.Backpack
toolReplica.Parent = hotbar
end
if itemTabl[id].itemType == "pack" then
local pack = packs:FindFirstChild(itemTabl[id].name):Clone()
pack.Parent = hotbar
end
end
local packID = saveData[plr.UserId].pack
local pack = packs:WaitForChild(itemTabl[packID].name):Clone()
local char = plr.Character
local torso = char:WaitForChild("Torso")
local weld = Instance.new("Weld")
weld.Name = "PackJoint"
weld.Parent = torso
weld.Part0 = torso
weld.Part1 = pack:WaitForChild("Bag")
weld.C0 = CFrame.new(0,0,0.95)
pack.Name = "Pack"
pack.Parent = char
event.Owned:FireClient(plr, saveData[plr.UserId].inventory)
end)
local 1:
local plrs = game:GetService("Players")
local uis = game:GetService("UserInputService")
local tweenServ = game:GetService("TweenService")
local starterGui = game:GetService("StarterGui")
local lighting = game:GetService("Lighting")
local rStore = game:GetService("ReplicatedStorage")
local maps = rStore:WaitForChild("Maps")
local event = rStore:WaitForChild("Events")
local loEvent = rStore:WaitForChild("LocalEvents")
local idSystem = require(rStore:WaitForChild("IDSystem"))
local shopInt = loEvent:WaitForChild("shopInt")
local plr = plrs.LocalPlayer
local mouse = plr:GetMouse()
local cam = workspace.CurrentCamera
local camTween
local char = plr.Character
local hum = char:WaitForChild("Humanoid")
local leaderstats = plr:WaitForChild("leaderstats")
local taps = leaderstats.Thingies
local cash = leaderstats.Wealth
local gui = plr.PlayerGui
local shopGui = gui.ShopGui
local leftButton = shopGui.Left
local rightButton = shopGui.Right
local buyButton = shopGui.Buy
local exitButton = shopGui.Exit
local flipButton = shopGui.Flip
local title = shopGui.Title
local price = shopGui.Price
local power = shopGui.Power
local shop = maps:WaitForChild("ShopView"):Clone()
local parts = shop:WaitForChild("Parts")
local packs = shop:WaitForChild("Packs")
local inShop = false
local onBuy = false
local flip = false
local option = 1
local pressed = 0
local poor = false
local lastCamPos = cam.CFrame
local itemTabl = idSystem.itemTabl
local textStuf = require(starterGui:WaitForChild("textStuf"))
local function optionGui()
title.Text = itemTabl[option].name
price.Text = "Price: $".. textStuf.aberviate(itemTabl[option].price)
if flip then
flipButton.Text = "Parts (S)"
power.Text = "Space: ".. textStuf.aberviate(itemTabl[option].power)
else
flipButton.Text = "Packs (S)"
power.Text = "Power: ".. textStuf.aberviate(itemTabl[option].power)
end
end
local function cameraPan()
pressed = 0
poor = false
if not flip then
local part = parts["option".. tostring(option)].CamAnchor
camTween = tweenServ:Create(cam, TweenInfo.new(0.5, Enum.EasingStyle.Cubic, Enum.EasingDirection.Out), {CFrame = part.CFrame * CFrame.Angles(math.rad(-15),0,0) + Vector3.new(0,2,5)})
camTween:Play()
else
local pack = packs["option".. tostring(option)].CamAnchor
camTween = tweenServ:Create(cam, TweenInfo.new(0.5, Enum.EasingStyle.Cubic, Enum.EasingDirection.Out), {CFrame = pack.CFrame * CFrame.Angles(math.rad(-15),0,0) + Vector3.new(0,2,-5)})
camTween:Play()
end
end
local function purchaseGui()
if itemTabl[option].owned then
buyButton.BackgroundColor3 = Color3.new(0,0,0)
buyButton.Text = "Owned"
buyButton.Active = false
buyButton.Interactable = false
return
else
buyButton.Text = "Purchase?"
buyButton.BackgroundColor3 = Color3.new(0, 255, 0)
buyButton.Active = true
buyButton.Interactable = true
end
end
local function purchase()
if itemTabl[option].owned then
return
end
buyButton.BackgroundColor3 = Color3.new(0,1,0)
buyButton.Text = "Purchase?"
pressed += 1
if poor then
poor = false
pressed = 0
end
if pressed == 1 then
buyButton.Text = "Confirm?"
elseif pressed >= 2 then
if cash.Value >= itemTabl[option].price then
print(plr.Name.." Bought ".. itemTabl[option].name)
event.Buy:FireServer(option)
pressed = 0
buyButton.BackgroundColor3 = Color3.new(0,0,0)
buyButton.Text = "Owned"
buyButton.Active = false
buyButton.Interactable = false
mouse.Icon = ""
return
else
pressed = 0
poor = true
buyButton.Text = "ur broke"
buyButton.BackgroundColor3 = Color3.new(255,0,0)
end
end
end
local function flipOptions()
if flip then
flip = false
option -= 19
else
flip = true
option += 19
end
optionGui()
purchaseGui()
cameraPan()
end
event.Owned.OnClientEvent:Connect(function(inventoryTabl)
print("local 1 recieved")
for i,id in ipairs(inventoryTabl) do
itemTabl[id].owned = true
end
if itemTabl[option].owned then
buyButton.BackgroundColor3 = Color3.new(0,0,0)
buyButton.Text = "Owned"
else
buyButton.BackgroundColor3 = Color3.new(0, 255, 0)
buyButton.Text = "Purchase?"
end
end)
shopInt.Event:Connect(function()
inShop = true
hum.WalkSpeed = 0
shop.Parent = workspace
starterGui:SetCoreGuiEnabled(Enum.CoreGuiType.PlayerList, false)
if itemTabl[option].owned then
buyButton.BackgroundColor3 = Color3.new(0,0,0)
buyButton.Text = "Owned"
else
buyButton.BackgroundColor3 = Color3.new(0, 255, 0)
buyButton.Text = "Purchase?"
end
lastCamPos = cam.CFrame
shopGui.Enabled = true
cam.CameraType = Enum.CameraType.Scriptable
optionGui()
if flip then
cam.CFrame = packs:WaitForChild("option".. tostring(option)):WaitForChild("CamAnchor").CFrame * CFrame.Angles(math.rad(-15),0,0) + Vector3.new(0,2,-5)
else
cam.CFrame = parts:WaitForChild("option".. tostring(option)):WaitForChild("CamAnchor").CFrame * CFrame.Angles(math.rad(-15),0,0) + Vector3.new(0,2,5)
end
end)
uis.InputBegan:Connect(function(input, gpe)
if not gpe and inShop then
if inShop and input.KeyCode == Enum.KeyCode.D or input.KeyCode == Enum.KeyCode.A then
if input.KeyCode == Enum.KeyCode.D then
if not flip then
option += 1
if option > 19 then
option = 1
end
else
option -= 1
if option < 20 then
option = 38
end
end
elseif input.KeyCode == Enum.KeyCode.A then
if not flip then
option -= 1
if option < 1 then
option = 19
end
else
option += 1
if option > 38 then
option = 20
end
end
end
optionGui()
purchaseGui()
cameraPan()
end
if input.KeyCode == Enum.KeyCode.S then
if not shopInt then return end
flipOptions()
end
end
end)
rightButton.MouseButton1Down:Connect(function()
if not inShop then return end
if not flip then
option += 1
if option > 19 then
option = 1
end
else
option -= 1
if option < 20 then
option = 38
end
end
optionGui()
purchaseGui()
cameraPan()
end)
leftButton.MouseButton1Down:Connect(function()
if not inShop then return end
if not flip then
option -= 1
if option < 1 then
option = 19
end
else
option += 1
if option > 38 then
option = 20
end
end
optionGui()
purchaseGui()
cameraPan()
end)
buyButton.Activated:Connect(function()
if not inShop then return end
purchase()
end)
exitButton.Activated:Connect(function()
inShop = false
hum.WalkSpeed = 16
if camTween then
camTween:Cancel()
end
cam.CameraType = Enum.CameraType.Custom
cam.CFrame = lastCamPos
shopGui.Enabled = false
starterGui:SetCoreGuiEnabled(Enum.CoreGuiType.PlayerList, true)
end)
flipButton.Activated:Connect(function()
if not shopInt then return end
flipOptions()
end)
local 2:
local plrs = game:GetService("Players")
local debris = game:GetService("Debris")
local uis = game:GetService("UserInputService")
local tweenServ = game:GetService("TweenService")
local starterGui = game:GetService("StarterGui")
local lighting = game:GetService("Lighting")
local rStore = game:GetService("ReplicatedStorage")
local stuff = rStore:WaitForChild("Stuff")
local parts = stuff:WaitForChild("Parts")
local packs = stuff:WaitForChild("Packs")
local maps = rStore:WaitForChild("Maps")
local event = rStore:WaitForChild("Events")
local uEvent = rStore:WaitForChild("UEvents")
local inventory = rStore:WaitForChild("LocalInventory")
local modls = rStore:WaitForChild("Models")
local oldModel
local spinTween
local spinAng = 0
local idSystem = require(rStore:WaitForChild("IDSystem"))
local plrData = event.GetData:InvokeServer()
local plr = plrs.LocalPlayer
local mouse = plr:GetMouse()
local cam = workspace.CurrentCamera
local char = plr.Character
local pack = char:WaitForChild("Pack")
local packID = pack:WaitForChild("ID").Value
local leaderstats = plr:WaitForChild("leaderstats")
local taps = leaderstats.Thingies
local cash = leaderstats.Wealth
local plrGui = plr.PlayerGui
local regGui = plrGui:WaitForChild("RegularGui")
local statFrame = regGui.GuiFrame
local cashDisplay = statFrame.CashDisplay
local tapDisplay = statFrame.TapsDisplay
local spaceBar = statFrame.SpaceBar
local bar = spaceBar.Bar
local spaceBarTaps = spaceBar.Taps
local spaceBarStorage = spaceBar.Storage
local StuffButton = statFrame.StuffButton
local petButton = statFrame.PetsButton
local inventoryFrame = regGui.InventoryFrame
local contents = inventoryFrame.Contents
local exitClip = inventoryFrame.ExitClippingFrame
local info = inventoryFrame.Info
local partFrame = contents.PartsFrame
local packFrame = contents.PacksFrame
local packGrid = packFrame.UIGridLayout
local partGrid = partFrame.UIGridLayout
local viewFrame = inventoryFrame.ViewFrame
local viewPort = viewFrame.ViewportFrame
local viewCam = Instance.new("Camera")
viewCam.Name = "ViewportCam"
viewCam.Parent = viewPort
local tweenVal = Instance.new("IntValue")
tweenVal.Name = "tweenVal"
tweenVal.Parent = viewCam
viewPort.CurrentCamera = viewCam
regGui.Enabled = true
--Funcs
local function cellSetup()
local partGridOffset = UDim2.new(0,(partGrid.CellSize.X.Scale * partFrame.AbsoluteSize.X),0,(partGrid.CellSize.Y.Scale * partFrame.AbsoluteSize.Y))
local packGridOffset = UDim2.new(0,(packGrid.CellSize.X.Scale * packFrame.AbsoluteSize.X),0,(packGrid.CellSize.Y.Scale * packFrame.AbsoluteSize.Y))
partGrid.CellSize = partGridOffset
packGrid.CellSize = packGridOffset
end
local function sizeAdjust()
local absPartSize = partGrid.AbsoluteContentSize
local absPackSize = packGrid.AbsoluteContentSize
if absPackSize == Vector2.new(0,0) then
absPackSize = Vector2.new(200,400)
end
if absPartSize == Vector2.new(0,0) then
absPackSize = Vector2.new(200,400)
end
partFrame.Size = UDim2.new(1,0,0.025,absPartSize.Y)
packFrame.Size = UDim2.new(1,0,0.025,absPackSize.Y)
end
--Setup
cellSetup()
sizeAdjust()
--Events
event.Owned.OnClientEvent:Connect(function(InventoryDict)
print("local 2 recieved")
inventory:ClearAllChildren()
for i, ID in ipairs(InventoryDict) do
local itemType = idSystem.itemTabl[ID].itemType
if itemType == "part" then
local itemClone = parts:WaitForChild(idSystem.itemTabl[ID].name):Clone()
itemClone.Parent = inventory
end
if itemType == "pack" then
local itemClone = packs:WaitForChild(idSystem.itemTabl[ID].name):Clone()
itemClone.Parent = inventory
end
end
end)
--Testy stuff
regGui:GetPropertyChangedSignal("AbsoluteSize"):Connect(function()
sizeAdjust()
end)
--Updating ViewportCam w Tweenval
tweenVal.Changed:Connect(function()
local tau = 2 * math.pi
local radius = 3
local A = math.rad(tweenVal.Value)
viewCam.CFrame = CFrame.lookAt(Vector3.new(math.sin(A)*radius, 0, math.cos(A)*radius), Vector3.new())
end)
type or paste code here