Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Int Values And Leader Board Stats?

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

2 comments

0

Provide the error made by the console

0

Is this in a server script? If so it won't work.

2 answers

✓ Accepted answer

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)

4 comments

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

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

0

@DanzLua I just changed it would it work in starter gui?

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

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

This discussion is preserved as it was. New answers, comments, and votes are closed.