Hello! I’ve been trying to make this work for the past hours but cannot seem to get this to work. Can somebody help me out with this? I would greately appreciate it.
So, what I’m trying to achieve is making the tupple from FireServer go to OnServerEvent , I’ve checked everything and still can’t seem to get this to work. It always says that the tupple is “nil”.
Local Script:
Summary
local rs = game:GetService("ReplicatedStorage")
local remoteEvent = rs:WaitForChild("OnItemBought")
local playerGUI = game.Players.LocalPlayer:WaitForChild("PlayerGui")
local shopFrame = playerGUI.ShopGui:WaitForChild("ShopBG")
local itemScroller = shopFrame.ItemScroller
local itemPreview = shopFrame.ItemPreview
local itemFolderReference = game.ReplicatedStorage:WaitForChild("ShopItems")
local itemsFolder = itemFolderReference:GetChildren()
for i, item in ipairs(itemsFolder) do
-- IGNORE THIS
itemScroller.ItemSelection1.MouseButton1Down:Connect(function()
itemPreview.ItemName.Text = itemsFolder[1].name
itemPreview.BuyButton.Text = "Buy for " .. itemsFolder[1].ShopGuiInfo.Price.Value
itemPreview.ItemDescription.Text = itemsFolder[1].ShopGuiInfo.Description.Value
itemPreview.Visible = true
end)
itemScroller.ItemSelection2.MouseButton1Down:Connect(function()
itemPreview.ItemName.Text = itemsFolder[2].name
itemPreview.BuyButton.Text = "Buy for " .. itemsFolder[2].ShopGuiInfo.Price.Value
itemPreview.ItemDescription.Text = itemsFolder[2].ShopGuiInfo.Description.Value
itemPreview.Visible = true
end)
end
-- Firing Event
itemPreview.BuyButton.MouseButton1Click:Connect(function()
print("Success!")
game.ReplicatedStorage.OnItemBought:FireServer(itemsFolder[itemPreview.ItemName.Text])
end)
Script:
Summary
local items = game.ReplicatedStorage:WaitForChild("ShopItems")
local itemFolderReference = game.ReplicatedStorage:WaitForChild("ShopItems")
local itemsFolder = itemFolderReference:GetChildren()
game.ReplicatedStorage:WaitForChild("OnItemBought").OnServerEvent:Connect(function(plr, tool)
print(tool)
if tool and tool:IsA("Tool") then
local cash = plr.leaderstats.Cash
if cash.Value >= tool.ShopGuiInfo.Price.Value then
cash.Value -= tool.ShopGuiInfo.Price.Value
tool:Clone().Parent = plr.Backpack
end
else
print("Error!! JHFIAJAFAWFAWGAWG")
end
end)