Thanks for the effort, but that LocalScript is not in ServerScriptService, it is in StarterGUI. I also tried your idea for the server script, but that has the same results.
For more information, here is the local script:
local modelName = script.Parent.Parent.ModelName
local boxName = script.Parent.Parent.Parent.CurrentBox
script.Parent.MouseButton1Click:Connect(function()
local outcome = game.ReplicatedStorage.CreateTransaction:InvokeServer(modelName.Value)
if outcome == true then
-- Purchase was successful
script.Parent.Text = "Equipped"
elseif outcome == "not enough coins" then
-- They do not have enough cash
elseif outcome == "already bought" then
if game.Players.LocalPlayer.Backpack.Value ~= modelName.Value then
game.ReplicatedStorage.EquipTool:FireServer(modelName.Value)
script.Parent.Text = "Equipped"
end
end
end)
boxName:GetPropertyChangedSignal(âValueâ):Connect(function()
local model = nil
for i, object in pairs(game.Workspace.ItemRoller["Box"..boxName.Value]:GetChildren()) do
if object:IsA("Model") then
model = object -- Swtting the model variable to the object
end
end
local toolsBought = game.ReplicatedStorage.GetToolsBought:InvokeServer()
for i, tool in pairs(toolsBought) do
if tool == model.Name then
-- Already bought by the player
script.Parent.Text = "Equipped"
else
script.Parent.Text = "Equip"
end
end
end)
and here is the Server Script:
â Generate Blocks â
local numberOfBlocks = #game:GetService(âServerStorageâ):WaitForChild(âToolModelsâ):GetChildren()
local studGap = 9 â Gab between each box
local box = game.Workspace:WaitForChild(âItemRollerâ).Box0
for i = 1,numberOfBlocks-1,1 do
newbox = box:Clone()
newbox:SetPrimaryPartCFrame(newbox.PrimaryPart.CFrame * CFrame.new(-16*i,0,0))
newbox.Name = âBoxââŚi
newbox.Parent = game.Workspace.ItemRoller
end
for i, v in pairs(game.ServerStorage.ToolModels:GetChildren()) do
if v then
new = v:Clone()
new:SetPrimaryPartCFrame(game.Workspace.ItemRoller[âBoxââŚi-1].Hitbox.CFrame)
new.Parent = game.Workspace.ItemRoller[âBoxââŚi-1]
end
end
game.ReplicatedStorage:WaitForChild(âRequestInformationâ).OnServerInvoke = function(plr,item)
local data = {}
local bought = false
local description = game.ServerStorage.ToolModels[item.Name].Information.Description.Value
local title = item.Name
local cost = game.ServerStorage.ToolModels[item.Name].Information.Cost.Value
local costType = game.ServerStorage.ToolModels[item.Name].Information.CostType.Value
if game.ServerStorage.PlayerTools[plr.Name]:FindFirstChild(item.Name) then
-- They have bought it
bought = true
else
bought = false
end
table.insert(data,1,title)
table.insert(data,2,description)
table.insert(data,3,cost)
table.insert(data,4,costType)
table.insert(data,5,bought)
return data
end
game.ReplicatedStorage.CreateTransaction.OnServerInvoke = function(player,item)
local coins = player:WaitForChild(âleaderstatsâ).Coins
local cost = game.ServerStorage.ToolModels[item].Information.Cost
if coins.Value >= cost.Value and not game.ServerStorage.PlayerTools[player.Name]:FindFirstChild(item) then
-- Player has enough money --
coins.Value = coins.Value - cost.Value
player.Character.Humanoid:UnequipTools()
for i, tool in pairs(player.Backpack:GetChildren()) do
if tool.Name == player.Equipped.Value then
tool:Destroy()
end
end
player.Equipped.Value = item
local tool = game.ServerStorage.Tools:FindFirstChild(item):Clone()
tool.Parent = game.ServerStorage.PlayerTools[player.Name]
local tool = game.ServerStorage.Tools:FindFirstChild(item):Clone()
tool.Parent = player.Backpack
return true
elseif cost.Value > coins.Value and not game.ServerStorage.PlayerTools [player.Name]:FindFirstChild(item) then
return "not enough coins"
else
return "already bought"
end
end
game.ReplicatedStorage.GetToolsBought.OnServerInvoke = function(player)
local tools = {}
for i, tool in pairs(game.ServerStorage.PlayerTools[player.Name]:GetChildren()) do
table.insert(tools,tool.Name)
end
return tools
end