I'm doing my stats gui, most every time a number is added I have to reset the character to change how do I change the gui the moment I click?
Script at the numbers:
local player = game.Players.LocalPlayer local userId = player.UserId local Data = player:WaitForChild("Data") local Stats = script.Parent local SkillPoints = Stats:WaitForChild("SkillPoints") local Defense = Stats:WaitForChild("Defense") local Health = Stats:WaitForChild("Health") local MaxMana = Stats:WaitForChild("MaxMana") local ManaDamage = Stats:WaitForChild("ManaDamage") local MaxStamina = Stats:WaitForChild("MaxStamina") local Strength = Stats:WaitForChild("Strength") local Speed = Stats:WaitForChild("Speed") Defense.Text = ""..Data.Defense.value Health.Text = ""..Data.Health.value MaxMana.Text = ""..Data.MaxMana.value ManaDamage.Text = ""..Data.ManaDamage.value MaxStamina.Text = ""..Data.MaxStamina.value Strength.Text = ""..Data.Strength.value Speed.Text = ""..Data.Speed.value SkillPoints.Text = ""..Data.SkillPoints.Value` --Script upgrade stats: local player = game.Players.LocalPlayer local Data = player:WaitForChild("Data") local Button = script.Parent function onClick() Data.Speed.Value = Data.Speed.Value + 1 Data.SkillPoints.Value = Data.SkillPoints.Value - 1 script.Sound:Play() end Button.MouseButton1Click:connect(onClick)
Im sure theres a more efficient way to do this, and an easier way(just a basic while loop), but this is how i'd go about it.
local player = game.Players.LocalPlayer local userId = player.UserId local Data = player:WaitForChild("Data") local Stats = script.Parent local SkillPoints = Stats:WaitForChild("SkillPoints") local Defense = Stats:WaitForChild("Defense") local Health = Stats:WaitForChild("Health") local MaxMana = Stats:WaitForChild("MaxMana") local ManaDamage = Stats:WaitForChild("ManaDamage") local MaxStamina = Stats:WaitForChild("MaxStamina") local Strength = Stats:WaitForChild("Strength") local Speed = Stats:WaitForChild("Speed") Defense.Changed:Connect(function() Defense.Text = ""..Data.Defense.Value end) Health.Changed:Connect(function() Health.Text = ""..Data.Health.Value end) MaxMana.Changed:Connect(function() MaxMana.Text = ""..Data.MaxMana.Value end) ManaDamage.Changed:Connect(function() ManaDamage.Text = ""..Data.ManaDamage.Value end) MaxStamina.Changed:Connect(function() MaxStamina.Text = ""..Data.MaxStamina.Value end) Strength.Changed:Connect(function() Strength.Text = ""..Data.Strength.Value end) Speed.Changed:Connect(function() Speed.Text = ""..Data.Speed.Value end) SkillPoints.Changed:Connect(function() SkillPoints.Text = ""..Data.SkillPoints.Value end) --Script upgrade stats: --local player = game.Players.LocalPlayer ----- Don't define player twice local Data = player:WaitForChild("Data") local Button = script.Parent function onClick() Data.Speed.Value = Data.Speed.Value + 1 Data.SkillPoints.Value = Data.SkillPoints.Value - 1 script.Sound:Play() end Button.MouseButton1Click:Connect(onClick) -- Connect not connect