Hello devleopers, i want to make a shop system with owned items (not a buy item again just equip) i have a local script with the scripts, but i don’t know how to make owned items.
I want to make:
- Equip Items
newTemplate script:
local folder = game.ReplicatedStorage:WaitForChild("Tools")
local frame = script.Parent:WaitForChild("Items")
local template = frame:WaitForChild("Template")
for _, tool in pairs(folder:GetChildren()) do
local newTemplate = template:Clone()
newTemplate.Name = tool.Name
newTemplate.ObjectName.Text = tool.Name
newTemplate.Visible = true
newTemplate.Parent = frame
local object = tool:Clone()
object.Parent = newTemplate.ViewportFrame
local camera = Instance.new("Camera")
camera.CFrame = CFrame.new(object.Handle.Position + (object.Handle.CFrame.lookVector*5)+Vector3.new(2,2,2), object.Handle.Position)
camera.Parent = newTemplate.ViewportFrame
newTemplate.ViewportFrame.CurrentCamera = camera
newTemplate.MouseButton1Click:Connect(function()
local result = game:GetService("ReplicatedStorage").Events.Buy:InvokeServer(tool.Name)
if result == true then
newTemplate.BackgroundColor3 = Color3.fromRGB(55,255,85)
else
newTemplate.BackgroundColor3 = Color3.fromRGB(255,60,0)
end
wait(1)
newTemplate.BackgroundColor3 = Color3.fromRGB(255,255,255)
end)
end
buy event script:
replic.Buy.OnServerInvoke = function(player, toolName)
local tool = game.ReplicatedStorage.Tools:FindFirstChild(toolName)
if tool and not player.StarterGear:FindFirstChild(toolName) then
if tool:FindFirstChild("Cost") then
if tool.Cost.Value <= player.leaderstats.Deti.Value then
-- buy
player.leaderstats.Deti.Value -= tool.Cost.Value
local newTool = tool:Clone()
newTool.Parent = player.Backpack
local newTool = tool:Clone()
newTool.Parent = player.StarterGear
return true
else
return false
end
else
return false end
end
end