I have a bug with my duplicating in shop

Hello developers

  1. So I want something like when u buy a tool from shop, I want to fix the bug so you can’t buy multiple one’s only one and after you bought it a textlabel will set the property to visible = true and if you try to buy again an error sound will play

  2. This is what i got: if player.Backpack:FindFirstChild(toolname) or player.Character:FindFirstChild(toolname) then return end; print("bought")

Btw the system is like once the remote events get fired on client it will give you the tool and play a bought sound

Thanks

Do your tools saves? (datastore accessing)

Yes I got a script that saves the tools.

Okay, there small script you can try, just replace part which you need
Its part of localscript in button

local event = game.ReplicatedStorage.RemoteEvent
script.Parent.MouseButton1Down:Connect(function()
local plr = game.Players.LocalPlayer
if plr.Backpack:FindFirstChild("tool") then
print("tool bought") 
else
event:FireServer() 
end
end) 

Forgot to say, when you equipping the tool its moving to your character, so you can have 2 tools

To fix add where your tool checj also

or plr.Character:FindFirstChild("tool") 

doesn’t work i get no errors, this is just a check, can you make so it destroys the duplicate?

Btw the tools are in a folder in server storage.

You can make it so when you try to buy an item and it hasnt been bought yet, it gives you the item, and the text of the textbutton that you clicked on to buy the item will change to something like: You bought this item already, and you can use an if statement to determine wether the player already bought the item or not. Here’s an example code:

```script.Parent.Activated:Connect(function()
if toolbought.Value == false then -- boolvalue inside replicatedstorage
--give player tool
else
errorsound:Play-- errorsound inside soundservice
script.Parent.Text = "Already bought this!"
end)
--Script.Parent is the button that you buy the item with
1 Like

This is also literally something i wrote on my phone in 5 mins so if theres any errors tell me

I thibk its only for current place, after restarting the boolvalue will be already false again

Can i have your script u made?

well… it’s a 1k lines code that I been working im sorry I don’t want to share my hard work, it’s very risky to me.

Its fine then, ig try marking more with prints to check out where error starts

Soo… that works if the bool value is true then u can’t buy it, let me do some quick changes and I will come with another message

1 Like

You’ll have to save the boolvalue also usibg DataStore so it doesn’t reset every time you rejoin

1 Like

yeye i know and I think I got this working… thank you so much!

2 Likes

No Problem, glad it worked!
You can also try changing the BackgroundColor to something like grey(55,55,55) so players see immedantly if they bought the item or not, also, a better way to tell players that they bought the item instead of changing the text would be adding a notification system, you could also use it for like in-game events. If you don’t quite know how to create something like that you can ask me😀
Also this is just a suggestion so yeah Good luck with your game😀

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