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

How to make it when a player has 50 Gold, they get a tool from ReplicatedStorage?

Asked by 3 years ago
Edited 3 years ago

It's pretty simple, except, i dont know how to do it.

I just need a script that gives the player a tool on spawn if they have 50 Gold.

Thank you for Helping!

0
This is not a request website. Please review the community guidelines before posting a question. appxritixn 2235 — 3y

3 answers

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

Hopefully, this answers your question if it did please accept my answer.

This script will check each time a player's gold is updated and if the value is over or equal to 50 gold it will give it the tool.

The tool part you have to do yourself because I do not know what the tool's name is.

I've tested the script and it should work perfectly only you have to remember to change the tool's name in line 13

local Players = game:GetService("Players")

local ReplicatedStorage = game:GetService("ReplicatedStorage")

Players.PlayerAdded:Connect(function(player)

    while true do
        wait(.5)
        local PlayerGold = player.leaderstats.Gold

        if PlayerGold.Value >= 50 then -- When a player gets 50 or more gold he gets the tool

            local ToolCopy = ReplicatedStorage.Tool:Clone() -- Change where it says ("Tool") to your tool's name
            ToolCopy.Parent = player.Backpack

            script:Destroy()
            break
        end 


    end
end)
0
This Looped it. Do you think you can make one that doesn't loop? Julien999111 0 — 3y
0
It gave me so many that the inventory ScrollingFrame ran out of space Julien999111 0 — 3y
0
Hahaha forgot about that one I will just edit my aswer :D johnoscarbhv1 137 — 3y
0
Fixed it so when the if thing works the loop will break and not give you anything more johnoscarbhv1 137 — 3y
Ad
Log in to vote
0
Answered by 3 years ago

Where would this script go?

0
The script wold most likely go into ServerScriptService Oxprem 140 — 3y
Log in to vote
0
Answered by
Oxprem 140
3 years ago
Edited 3 years ago

So I decided to re-write johnoscarbhv1's script into something that won't continuously duplicate the tool. I didn't test it but I hope it works for you:

local Players = game:GetService("Players")

local ReplicatedStorage = game:GetService("ReplicatedStorage")

Players.PlayerAdded:Connect(function(player)
    local PlayerGold = player.leaderstats.Gold
    repeat wait(0.5) until PlayerGold.Value == 50 or PlayerGold.Value > 50
            local ToolCopy = ReplicatedStorage.Tool:Clone() -- Change where it says ("Tool") to your tool's name
            ToolCopy.Parent = player.Backpack
end)

Answer this question