Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to make this script check leaderboard enough money then take that amount?

Asked by 5 years ago

Please help make it so this script first checks leaderboard stats to see if you have enough money or more then take that amount and finish the rest of the code (please do not make it so it gives the item i just need it so it checks if player has enough money and takes that amount!)

script.Parent.MouseButton1Click:connect(function() if not game.Players.LocalPlayer.Backpack:FindFirstChild("SpeedCoil") then print("Giving "..game.Players.LocalPlayer.Name.." Item.") Sword = game.Lighting.SpeedCoil:Clone() Sword.Parent = game.Players.LocalPlayer.Backpack elseif game.Players.LocalPlayer:FindFirstChild("SpeedCoil") then print(game.Players.LocalPlayer.Name.." Already received the item.") end end)

Thank you for your time! Please help me out!

0
place your code in a code block pls hellmatic 1523 — 5y
0
Maybe I Can Figure That Out! Mind If I Share You Another Script? friendman7000 3 — 5y
0
Do not use lighting as storage. User#21908 42 — 5y

1 answer

Log in to vote
0
Answered by
AIphanium 124
5 years ago
Edited 5 years ago

Hello, thekittinking84!

All you have to do is pretty simple, so i have edited the script for you :)


local cost = 45 script.Parent.MouseButton1Click:connect(function() if not game.Players.LocalPlayer.Backpack:FindFirstChild("SpeedCoil") and game.Players.LocalPlayer.leaderstats.Money >= cost then -- Note : you have to place a folder named "leaderstats" with an IntValue named "Money" inside the folder, now the folder has to be inside the player ( not backpack ). game.Players.LocalPlayer.leaderstats.Money = game.Players.LocalPlayer.leaderstats.Money - cost print("Giving "..game.Players.LocalPlayer.Name.." Item.") Sword = game.Lighting.SpeedCoil:Clone() Sword.Parent = game.Players.LocalPlayer.Backpack elseif game.Players.LocalPlayer.Backpack:FindFirstChild("SpeedCoil") then print(game.Players.LocalPlayer.Name.." Already received the item.") end end)

Here, put this script in ServerScriptService :/

local stats = script.leaderstats:Clone() -- Make sure that you have done the things in the last note, but this time place the folder INSIDE this script, and you are done!

game.Players.PlayerAdded:Connect(function(player)
stats.Parent = player
    end)
  • Accept the answer if this helped!

-- Hope i helped.

--- Edited!

---- AIphanium

0
It doesn't seem to be working but im new could i have a screenshot to see where i have to put the leaderstats folder? DecaSide 0 — 5y
0
Edited my answer. AIphanium 124 — 5y
Ad

Answer this question