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

How would I make a button that gives a +1 on each stat?

Asked by 6 years ago
01game.Players.PlayerAdded:connect(function(player)
02    player.characteradded:Connect(function(char)
03        local data = Instance.new("Folder", player)
04        data.Name = "Stats"
05 
06        local Strength = Instance.new("IntValue", data)
07        Strength.Name = "Strength"
08        Strength.Value = 0
09 
10        local Defense = Instance.new("IntValue", data)
11        Defense.Name = "Defense"
12        Defense.Value = 0
13 
14        local Agility = Instance.new("IntValue", data)
15        Agility.Name = "Agility"
View all 22 lines...
0
Any attempt on this? And also the parent argument of Instance.new is deprecated. User#19524 175 — 6y
0
for the parent value, try this: local Strength = Instance.new("IntValue") Strength.Parent = data Strength.Name = "Strength" Strength.Value = 0 the +1 is this: Strength.Value = Strength.Value + 1 supermariodeadtolive 55 — 6y
0
The whole point of not using the parent argument is setting the properties before the parent, such as Name and Value, is it not? masterblokz 58 — 6y

2 answers

Log in to vote
1
Answered by
CjayPlyz 643 Moderation Voter
6 years ago
Edited 6 years ago

For this to work put a click detector inside the button.

1local button = script.Parent -- replace with the location of the button
2 
3button.ClickDetector.MouseClick:Connect(function(player)
4    player.Stats.Strength.Value = player.Stats.Strength.Value + 1
5    player.Stats.Defense.Value = player.Stats.Defense.Value + 1
6    player.Stats.Agility.Value = player.Stats.Agility.Value + 1
7    player.Stats.Skill.Value = player.Stats.Skill.Value + 1
8end)

if it doesn't work tell me.

0
Works! ZapherosX 43 — 6y
0
Np :) CjayPlyz 643 — 6y
Ad
Log in to vote
0
Answered by 6 years ago
Edited 6 years ago
01wait()
02local button = script.Parent
03local player = game.Players.LocalPlayer
04local stats = player:WaitForChild("stats")
05button.MouseButton1Click:Connect(function()
06    stats.Strength.Value = stats.Strength.Value + 1
07    stats.Defense.Value = stats.Defe.Value + 1
08    stats.Agility.Value = stats.Agility.Value + 1
09    stats.Skill.Value = stats.Skill.Value + 1
10end)

?

Answer this question