I'm trying to give myself stats for a game and it keeps giving me errors.
script.Parent.Parent.Players.LocalPlayer.PlayerGui.Interface.ButtonSideInterface.Rebirth.TextButton.MouseButton1Click:Connect(function() print("Rebirthing") if game.Players.LocalPlayer.leaderstats.Money == 100000 * game.Players.LocalPlayer.leaderstats.Rebirths then game.Players.LocalPlayer.leaderstats.Money = 0 game.Players.LocalPlayer.leaderstats.Rebirths = game.Players.LocalPlayer.leaderstats.Rebirths.Value + 1 else script.Parent.Parent.Players.LocalPlayer.PlayerGui.Interface.MessageBox.Frame.Message.Text = "You do not have enough money to purchase this item!" script.Parent.Parent.Players.LocalPlayer.PlayerGui.Interface.MessageBox.Frame.Top.Text = "Oops!" script.Parent.Parent.Players.LocalPlayer.PlayerGui.Interface.MessageBox.MessageBox.Button.Text = "Ok." print("Rebirth failed due to invalid stats.") end 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:
script.Parent.MouseButton1Click:Connect(function() game:GetService("ReplicatedStorage").rebirth:FireServer() end)
And put that in a server script
game:GetService("ReplicatedStorage").rebirth.OnServerEvent:Connect(function(plr) print("Rebirthing") if plr.leaderstats.Money.Value == 100000 * plr.leaderstats.Rebirths.Value then plr.leaderstats.Money.Value = 0 plr.leaderstats.Rebirths.Value = plr.leaderstats.Rebirths.Value + 1 else plr.PlayerGui.Interface.MessageBox.Frame.Message.Text = "You do not have enough money to purchase this item!" plr.PlayerGui.Interface.MessageBox.Frame.Top.Text = "Oops!" plr.PlayerGui.Interface.MessageBox.Frame.Button.Text = "Ok." print("Rebirth failed due to invalid stats.") end end)
You have to type .Value to add to something. Let me show you:
Script running server sided
game.Players.PlayerAdded:Connect(function(p) if p.leaderstats.Money.Value == 100000 * p.leaderstats.Rebirths.Value then p.leaderstats.Money.Value = 0 p.leaderstats.Rebirths = p.leaderstats.Rebirths.Value +1 else p:WaitForChild("PlayerGui").Interface.MessageBox.Frame.Message.Text = "You do not have enough money to purchase this item!" p:WaitForChild("PlayerGui").Interface.MessageBox.Frame.Top.Text = "Oops!" p:WaitForChild("PlayerGui").Interface.MessageBox.MessageBox.Button.Text = "Ok." print("Rebirth failed due to invalid stats.") end end)
local player = script.Parent.Parent player.PlayerGui.Interface.ButtonSideInterface.Rebirth.TextButton.MouseButton1Click:Connect(function() print("Rebirthing") if player.leaderstats.Money == 100000 * player.leaderstats.Rebirths then player.leaderstats.Money = 0 player.leaderstats.Rebirths = player.leaderstats.Rebirths.Value + 1 else player.PlayerGui.Interface.MessageBox.Frame.Message.Text = "You do not have enough money to purchase this item!" player.PlayerGui.Interface.MessageBox.Frame.Top.Text = "Oops!" player.PlayerGui.Interface.MessageBox.MessageBox.Button.Text = "Ok." print("Rebirth failed due to invalid stats.") end end)