I'm trying to give myself stats for a game and it keeps giving me errors.
01 | script.Parent.Parent.Players.LocalPlayer.PlayerGui.Interface.ButtonSideInterface.Rebirth.TextButton.MouseButton 1 Click:Connect( function () |
02 | print ( "Rebirthing" ) |
03 | if game.Players.LocalPlayer.leaderstats.Money = = 100000 * game.Players.LocalPlayer.leaderstats.Rebirths then |
04 | game.Players.LocalPlayer.leaderstats.Money = 0 |
05 | game.Players.LocalPlayer.leaderstats.Rebirths = game.Players.LocalPlayer.leaderstats.Rebirths.Value + 1 |
06 | else |
07 | script.Parent.Parent.Players.LocalPlayer.PlayerGui.Interface.MessageBox.Frame.Message.Text = "You do not have enough money to purchase this item!" |
08 | script.Parent.Parent.Players.LocalPlayer.PlayerGui.Interface.MessageBox.Frame.Top.Text = "Oops!" |
09 | script.Parent.Parent.Players.LocalPlayer.PlayerGui.Interface.MessageBox.MessageBox.Button.Text = "Ok." |
10 |
11 | print ( "Rebirth failed due to invalid stats." ) |
12 | end |
13 | end ) |
Instead of rebirths it would be rebirths.Value on line 3 Also you forgot most of the .Value Make a RemoteEvent in replicated storage and name it "rebirth"
Put this in the local button:
1 | script.Parent.MouseButton 1 Click:Connect( function () |
2 | game:GetService( "ReplicatedStorage" ).rebirth:FireServer() |
3 | end ) |
And put that in a server script
01 | game:GetService( "ReplicatedStorage" ).rebirth.OnServerEvent:Connect( function (plr) |
02 | print ( "Rebirthing" ) |
03 | if plr.leaderstats.Money.Value = = 100000 * plr.leaderstats.Rebirths.Value then |
04 | plr.leaderstats.Money.Value = 0 |
05 | plr.leaderstats.Rebirths.Value = plr.leaderstats.Rebirths.Value + 1 |
06 | else |
07 | plr.PlayerGui.Interface.MessageBox.Frame.Message.Text = "You do not have enough money to purchase this item!" |
08 | plr.PlayerGui.Interface.MessageBox.Frame.Top.Text = "Oops!" |
09 | plr.PlayerGui.Interface.MessageBox.Frame.Button.Text = "Ok." |
10 |
11 | print ( "Rebirth failed due to invalid stats." ) |
12 | end |
13 | end ) |
You have to type .Value to add to something. Let me show you:
Script running server sided
01 | game.Players.PlayerAdded:Connect( function (p) |
02 | if p.leaderstats.Money.Value = = 100000 * p.leaderstats.Rebirths.Value then |
03 | p.leaderstats.Money.Value = 0 |
04 | p.leaderstats.Rebirths = p.leaderstats.Rebirths.Value + 1 |
05 | else |
06 | p:WaitForChild( "PlayerGui" ).Interface.MessageBox.Frame.Message.Text = "You do not have enough money to purchase this item!" |
07 | p:WaitForChild( "PlayerGui" ).Interface.MessageBox.Frame.Top.Text = "Oops!" |
08 | p:WaitForChild( "PlayerGui" ).Interface.MessageBox.MessageBox.Button.Text = "Ok." |
09 |
10 | print ( "Rebirth failed due to invalid stats." ) |
11 | end |
12 | end ) |
01 | local player = script.Parent.Parent |
02 |
03 | player.PlayerGui.Interface.ButtonSideInterface.Rebirth.TextButton.MouseButton 1 Click:Connect( function () |
04 | print ( "Rebirthing" ) |
05 | if player.leaderstats.Money = = 100000 * player.leaderstats.Rebirths then |
06 | player.leaderstats.Money = 0 |
07 | player.leaderstats.Rebirths = player.leaderstats.Rebirths.Value + 1 |
08 | else |
09 | player.PlayerGui.Interface.MessageBox.Frame.Message.Text = "You do not have enough money to purchase this item!" |
10 | player.PlayerGui.Interface.MessageBox.Frame.Top.Text = "Oops!" |
11 | player.PlayerGui.Interface.MessageBox.MessageBox.Button.Text = "Ok." |
12 |
13 | print ( "Rebirth failed due to invalid stats." ) |
14 | end |
15 | end ) |