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

Identify a Int Value and gives a Tool if its 1, another one if its 2...?

So I am making a game which I want to your Magic to be random when you level up, so I made a leaderboard for Level, Magic and Money like this:

game.Players.PlayerAdded:connect(function(p) local stats = Instance.new("IntValue") stats.Name = "leaderstats" stats.Parent = p

local nivel = Instance.new("IntValue")
nivel.Name = "Level"
nivel.Value = 1
nivel.Parent = stats

local magia = Instance.new("IntValue")
magia.Name = "Magic"
magia.Value = 0
magia.Parent = stats

local dinheiro = Instance.new("IntValue")
dinheiro.Name = "Valis"
dinheiro.Value = 0
dinheiro.Parent = stats

end)

I know this may sounds like a request but I want to know if magia.Value is 1 and if it is gives a tool of Lightning, if it is 2 gives another tool also in Lightning.

3 comments

0

Add the WHOLE script inside the code block

0

Its my first time posting here, but the site doesnt let me choose what is part of the code.

0

Wouldn't an If statement solve your question?

1 answer

✓ Accepted answer

You'd have to detect when magia is changed with the Changed() event. Then, you'd check if the value has changed to 1 or 2 with if-then and elseif-then statements, and if it has, you'd give the tool in the Lighting. Try putting this code under your magia code (at line 10, or anywhere before the end) would be fine.)

magia.Changed:connect(function() --Changed Event
	if magia.Value == 1 then --if-then statement
		game.Lighting.ToolName.Parent = p.Backpack --Tool Giver. Change ToolName to the name of the tool.
	elseif magia.Value == 2 then --elseif-then statement
		game.Lighting.ToolName.Parent = p.Backpack --Again, change ToolName to the name of the tool.
	end
end)

If it doesn't work, let me know. Make sure you change ToolName at line 3 and 5 to the names of the tools.

1 comment

0

Thank you very much! It worked exactly how I wanted.

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