So I am currently trying to make a shop for my group's game, Bloxxer. I have created 2 scripts for the game. One is a ServerInvoke script and the other is a purchase script. I keep getting this error: attempt to compare userdata with number Could anyone help? ServerInvoke:
game.ReplicatedStorage.PurchaseItem.OnServerInvoke = function(CertainPlayer, Item, Parent, Price)
if CertainPlayer:WaitForChild("leaderstats").Coins.Value >= Price then
CertainPlayer.leaderstats.Coins.Value = CertainPlayer.leaderstats.Coins.Value - Price
local Tool = Parent[Item]:Clone()
Tool.Parent = CertainPlayer.Backpack
local Tool = Parent[Item]:Clone()
Tool.Parent = CertainPlayer.StarterGear
return true
else
return false
end
end
Purchase:
local AlreadyPurchased = false
script.Parent.Text = "Buy for 15 Coins"
script.Parent.MouseButton1Click:Connect(function()
if AlreadyPurchased == false then
local CertainPlayer = game.Players.LocalPlayer
local Item = game.ReplicatedStorage.Shop.Items.FakeKnife.Tool.Name
local Parent = game.ReplicatedStorage.Shop.Items.FakeKnife
local Price = 15
local Purchased = game.ReplicatedStorage.PurchaseItem:InvokeServer(CertainPlayer, Item, Parent, Price)
if Purchased == true then
AlreadyPurchased = true
script.Parent.Text = "Purchased!"
wait(2.5)
script.Parent.Text = "Buy for 15 Coins"
else
script.Parent.Text = "Failed to purchase!"
wait(2.5)
script.Parent.Text = "Buy for 15 Coins"
end
elseif AlreadyPurchased == true then
script.Parent.Text = "Already purchased!"
wait(2.5)
script.Parent.Text = "Buy for 15 Coins"
end
end)

2 comments
Confused, what am I meant to do.
^ Didn't read all of it, but it worked! Thank you for the help!