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

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

Asked by 6 years ago
Edited 6 years ago

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.

0
Add the WHOLE script inside the code block hellmatic 1523 — 6y
0
Its my first time posting here, but the site doesnt let me choose what is part of the code. xSanjiVinsmoke 4 — 6y
0
Wouldn't an If statement solve your question? MooMooThalahlah 421 — 6y

1 answer

Log in to vote
0
Answered by
ax_gold 360 Moderation Voter
6 years ago

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.

0
Thank you very much! It worked exactly how I wanted. xSanjiVinsmoke 4 — 6y
Ad

Answer this question