Weird bug with my code

hey i am trying to make an server side event for purchasing item frog gui. for some reason its not founding the item name its says nil. i hope someone can help me with that :smiley:

server side:

local ReplicatedStorage = game:GetService("ReplicatedStorage")


ReplicatedStorage:FindFirstChild("Events"):FindFirstChild("AddItem").OnServerEvent:Connect(function(player,ItemName,price)
	if player then
		
		local ServerStorage = game:GetService("ServerStorage")
		local ItemsFolder = ServerStorage:WaitForChild("GameItems")
		
		if ItemsFolder:FindFirstChild(ItemName) then
			print("done3")
			if player.Backpack:FindFirstChild(ItemName) then print("already own") return end
			if player["שקלים"].Value >= price then
				player["שקלים"].Value = player["שקלים"].Value - price
				local Item = ItemsFolder:FindFirstChild(ItemName)
				Item:Clone().Parent = player.Backpack
			end
		else
			print("not found")
		end
	end
end)

button client side:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ItemsFolder = ReplicatedStorage:FindFirstChild("ShopItems")
local Event = ReplicatedStorage:FindFirstChild("Events"):FindFirstChild("AddItem")

script.Parent.Activated:Connect(function()
	local Player = game.Players.LocalPlayer
	local Item = script.Parent.Parent.Parent.Name
	local ItemPrice = tonumber(script.Parent.Parent.PriceBar.Price.Text)
	
	if ItemsFolder:FindFirstChild(Item) then
		local PurchasedItem = ItemsFolder:FindFirstChild(Item)
		print(ItemPrice)
		Event:FireServer(PurchasedItem,ItemPrice)
		--PurchasedItem:Clone().Parent = PlayerInventory
	else
		warn("item does not exsist")
	end		
end)

image

image
thats what i got in the server side, its passing the information good but in the findfirstchiled with that name it says nil its going to the else

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.