im trying to make it so if you pick something up it subtracts an intsValue Value by 100 and if you don't have 100 value on your intValue you can't pick it up
You would have to do the picking up part but here's a solution.
When a player has enough points he can pick it up and it subtracts it but the part will delete so you have to figure out that for yourself.
Leaderstats Script:
local Players = game:GetService("Players") Players.PlayerAdded:Connect(function(player) local leaderstats = Instance.new("Folder", player) leaderstats.Name = "leaderstats" local IntValStat = Instance.new("IntValue", leaderstats) IntValStat.Name = "IntValStat" IntValStat.Value = 500 -- The value of your intstat by default end)
Script in part:
-- Script in the part -- Normal Script local clickdetector = script.Parent.ClickDetector local part = script.Parent clickdetector.MouseClick:Connect(function(player) if player.leaderstats.IntValStat.Value >= 100 then -- if the player has 100 or more "points" then he gets to pick it up print("Player has enough money!") player.leaderstats.IntValStat.Value = player.leaderstats.IntValStat.Value - 100 -- Subtracts the points part:Destroy() else print("Player does not have enough money!") end end)