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

Int Values And Leader Board Stats?

Asked by 4 years ago

Hello,

I am trying to make a simulator were you fill your bag and you can sell it so I want to make my int value be what the leader board stat says so if I have 10 sand I want the int value to be 10. The error is with something about the Local Player you can't use. https://gyazo.com/8a3af66a223b3e5768242da4c9c1adbf | https://gyazo.com/50568a4009de6c4e5a883daf92174cee | https://gyazo.com/cb02073da77441536890e1dd0b474a5c

0
Provide the error made by the console DanzLua 2879 — 4y
0
Is this in a server script? If so it won't work. aiza_teizuki 15 — 4y

2 answers

Log in to vote
0
Answered by
DanzLua 2879 Moderation Voter Community Moderator
4 years ago
Edited 4 years ago

The reason this isn't working is because your local script appears to be located under workspace.

Localscripts must be parented to services such as StarterGui, StarterPack, and StarterPlayer to work.

If you really want this change to be done on the client (meaning only the player will have this value changed for them, after putting the localscript in an apropriate parent

workspace.Part.CurrentOre.Value=game.Players.LocalPlayer:WaitForChild("leaderstats"):WaitForChild("Sand").Value
--click view source, seems like the line is too long

Update: Changed the checker to the server where the backpack is created

game.Players.PlayerAdded:Connect(function(Player)
    local sand=Player:WaitForChild("leaderstats"):WaitForChild("Sand")
    Player.CharacterAdded:Connect(function(Character)
        local bucket= script.Parent.BasicBag:Clone()
        bucket.Parent = Character -- Rename Backpack to your backpack's name, and make sure this script and the backpack is in ServerScriptService
        local function change()
            bucket.Handle.Part.CurrentOre.Value=sand.Value
            bucket.Handle.Part.SurfaceGui.TextLabel.Text=sand.Value.."/"..bucket.Handle.Part.MaxOre.Value
        end
        sand.Changed:Connect(change)
        change()
    end)
end)
0
Hey dude that did not work the thing you gave to me because my Local script is in the backpack not that part that part in workspace is just there to give you the sand. https://gyazo.com/d1390958628e3a6bfe19d37fbd62101b you can see the Localscript inside of Current Ore witch is inside of the backpack Darthman522 10 — 4y
0
@Darthman522 CurrentOre shows to be in the ServerScriptSerivice, not the starterpack/backpack lol, and even if it ended up in the character, it's still in workspace DanzLua 2879 — 4y
0
@DanzLua I just changed it would it work in starter gui? Darthman522 10 — 4y
0
Dude it does not work I put that same script in all the folders and stuff it did not work the error was the same one I told you "CurrentOre is not a valid member of game.workspace.part" If you would like to go in team create friend request me Darthman522 10 — 4y
Ad
Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

It realy easy you need to put the script in a normal script and

just change "script.Parent.Value" to where the int-value is and "sand.leaderstats.sand.Value" to where the sand's value is

and here is a example script:

while true do

local player = game.Players.LocalPlayer

script.Parent.Value = player.leaderstats.Sand.Value

wait()

end

If you must use a local script then you must make a normal script in the same place then put/past the script the

Answer this question