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

can any one help me with this "required level" for a shop gui?

i made a shop gui but the problem is.I want players to have the cash and a required level to get the item or move ...so can anyone help me plz? i really want to know how...

--Tizzel40

3 comments

0

Wth? If you have a level system just do local player = game.Players.LocalPlayer and then if player.Level > (level) then the code....

0

ummmm ok

0

Without your code no one can help. This is ScriptingHelpers, not ScriptersDoItForMe.

1 answer

✓ Accepted answer

If you want a level system and a cash system you can create a simple script to create that. You need to create leaderstats which is what you use for creating cash and levels.

Make sure you read the comments in the code so you can see where something is happening

Example:

game.Players.PlayerAdded:Connect(function(plr)
	local Leaderstats = Instance.new("IntValue", plr)
	Leaderstats.Name = "leaderstats" -- Has to be a lower case l 

	local Cash = Instance.new("IntValue", Leaderstats)
	Cash.Name = "Cash" -- Name this whatever you want"

	local Level = Instance.new("IntValue", Leaderstats)
	Level.Name = "Level"
end)

Thats how you create a basic leaderboard. This will not save though. If you want a save system you will need to write some data store code.

local DataStore = game:GetService("DataStoreService"):GetDataStore("Name Data")

game.Players.PlayerAdded:Connect(function(plr)

	-- Remove local from all variables	

	Leaderstats = Instance.new("IntValue", plr)
	Leaderstats.Name = "leaderstats" -- Has to be a lower case l 

	Cash = Instance.new("IntValue", Leaderstats)
	Cash.Name = "Cash" -- Name this whatever you want"

	Level = Instance.new("IntValue", Leaderstats)
	Level.Name = "Level"

	-- Data Store Code Here
	
	-- Keep local on these variables
	
	local Key = "plr-"..plr.userId
	Saved = DataStore:GetAsync(Key)

	if Saved then
		Cash.Value = Saved[1]
		Level.Value = Saved[2]
	else
		local Values = {Cash.Value, Level.Value}
		DataStore:SetAsync(Key, Values)
	end
end)

game.Players.PlayerRemoving:Connect(function(plr)
	local Key = "plr-"..plr.userId
	local Values = {Cash.Value. Level.Value}

	DataStore:SetAsync(Key, Values)
end)

This will save your stats. Level system example:

-- User code above 

game.Players.PlayerAdded:Connect(function(plr)
	local Leaderstats = Instance.new("IntValue", plr)
	Leaderstats.Name = "leaderstats" -- Has to be a lower case l 

	local Cash = Instance.new("IntValue", Leaderstats)
	Cash.Name = "Cash" -- Name this whatever you want"

	local Level = Instance.new("IntValue", Leaderstats)
	Level.Name = "Level"
end)
local DataStore = game:GetService("DataStoreService"):GetDataStore("Name Data")

game.Players.PlayerAdded:Connect(function(plr)

	-- Remove local from all variables	

	Leaderstats = Instance.new("IntValue", plr)
	Leaderstats.Name = "leaderstats" -- Has to be a lower case l 

	Cash = Instance.new("IntValue", Leaderstats)
	Cash.Name = "Cash" -- Name this whatever you want"

	Level = Instance.new("IntValue", Leaderstats)
	Level.Name = "Level"

	-- Data Store Code Here
	
	-- Keep local on these variables
	
	local Key = "plr-"..plr.userId
	Saved = DataStore:GetAsync(Key)

	if Saved then
		Cash.Value = Saved[1]
		Level.Value = Saved[2]
	else
		local Values = {Cash.Value, Level.Value}
		DataStore:SetAsync(Key, Values)
	end
end)

game.Players.PlayerRemoving:Connect(function(plr)
	local Key = "plr-"..plr.userId
	local Values = {Cash.Value. Level.Value}

	DataStore:SetAsync(Key, Values)
end)

-- Level system below

local Toggle = false

local function LevelUp()
	if Toggle == false then
		local level = game.Players.LocalPlayer.leaderstats.Level
		
		level.Value = level.Value + 1

		Toggle = true
	end
end

-- If the player touches the level up part then they level up

game.Workspace.LevelPart.Touched:Connect(LevelUp)

You could also write the touched event function like this. This way you don't have to create the function LevelUp.

local Toggle = false

game.Workspace.LevelPart.Touched:Connect(function()
	
	if Toggle == false then
		local level = game.Players.LocalPlayer.leaderstats.Level
		
		level.Value = level.Value + 1
		
		Toggle = true
	end
end)

Here are some links to the topics I showed you:

Data Store http://wiki.roblox.com/index.php/Data_store

Leaderboards http://wiki.roblox.com/index.php/Leaderboards

Events http://wiki.roblox.com/index.php?title=RBXScriptSignal

Functions http://wiki.roblox.com/index.php/Function

Roblox scripting Basics http://wiki.roblox.com/index.php/Scripting_Book

Hope this helps!

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