The biggest issue in your script was your use of double quote marks( " ) and double dot ( … ), it looks like you were using different symbols, but similar.
Example:
You were using “
when you were supposed to use "
And using …
when you were supposed to use ..
Actually there’s one more issue, and it’s about the currency.
You put this:
local currency = player.leaderstats[player:WaitForChild(“PetShop”).Currency.Value]
Basically means this:
local currency = player.leaderstats[game.Players.LocalPlayer:WaitForChild(“PetShop”).Currency.Value]
I imagine you don’t have those folders(game.Players.LocalPlayer) inside your leaderstats
Then you could just use:
local currency = player.leaderstats:WaitForChild("PetShop").Currency.Value
Here is your code but written correctly:
local player = game.Players.LocalPlayer
local item = script.Parent.Parent.Parent.Item
local shop = game.Workspace.PetShop
local currency = player.leaderstats.Currency -- Change this to the correct directory
script.Parent.MouseButton1Click:Connect(function()
if script.Parent.TextLabel.Text == "Equip" and script.Parent.TextLabel.Text ~= "Equipped" then
script.Parent.TextLabel.Text = "Equipped"
script.Parent.BackgroundColor3 = Color3.new(0.7,0.7,0.7)
game.ReplicatedStorage.EquippedE:FireServer(item.Value)
end
if shop.Parts:FindFirstChild("Model" .. item.Value) then
if currency.Value >= shop.Parts:FindFirstChild("Model" .. item.Value).ItemPrice.Value then
if script.Parent.TextLabel.Text ~= "Equip" and script.Parent.TextLabel.Text ~= "Equipped" then
script.Parent.TextLabel.Text = "Equipped"
script.Parent.BackgroundColor3 = Color3.new(0.7,0.7,0.7)
game.ReplicatedStorage.EquippedE:FireServer(item.Value)
game.ReplicatedStorage.ShopBuyE:FireServer(item.Value)
end
end
end
end)
script.Parent.MouseButton1Click:Connect(function()
if script.Parent.TextLabel.Text == "Equipped" then
script.Parent.TextLabel.Text = "Equip"
player.Character.Pet:Destroy()
end
end)
IMPORTANT: In case you want to keep your game protected, it would be good if the currency check was on a server side script
I hope this works correctly, have a great day!
Edit: I understood now what you were trying to do on line 4, but I just realized that it has a .Value
at the end of it, and in the if statement it has a currency.Value
, it’s like you’re writing: currency.Value.Value
Put in line 4 where your currency will be, as far as I know, what you put will not return the value you want.
I imagine it looks like this:
local currency = player.leaderstats:WaitForChild("Currency")
Edit2: Maybe you used double quote marks and double dot correctly, but the devforum changed when publishing, the next time you send a code use:
```
Your code here
```
Example:
```
print(“Hello World!”)
```
Result:
print("Hello World!")