It is not a local script, it’s a normal script
Fails to work how? Throwing a block of code and saying it doesn’t work isn’t helpful to those who are looking through the thread and want to offer a potential fix.
Also, don’t handle Guis through a normal script, that’s bad practice. Use a LocalScript to handle the Gui and leave important interactions (giving of tool and subtraction of money) to the server. Use a remote to bridge this action.
local player = script:FindFirstAncestorOfClass(“Player”)
Turn this into a local script
Use
local player = game:GetService('Players').LocalPlayer
Send a remote fire to handle the purchase on the server
Custom Events and Callbacks | Documentation - Roblox Creator Hub (page currently down but for future reference)
RemoteEvent | Documentation - Roblox Creator Hub
The idea is if the player has enough cash on their leaderstats it gives them the tools, but it is saying they don’t have enough money, if I changed the leaderstats during a test play would it work?
You’re most likely changing it on the client which won’t replicate then
Okay, I’ll test this on a live server, I’ll tell you whether or not this works.
No, that’s not the problem. It’s that you’re handling the Gui wrong. You shouldn’t use a server script for any kind of interface. A fundamental problem is your implementation itself and you should fix that before you go on to try and debug the problem, which is a product of the bad code structure in the first place.