I was trying to define a player in a leaderstats DataStore2 script for rebirths since if i use
if player:FindFirstChild("leaderstats") and
player.leaderstats:FindFirstChild("Rebirths")
player.leaderstats.Rebirths.Value = player.leaderstats.Rebirths.Value + 1
This wouldn't work since my DataStore2 script prevents updated values in the IntValue in the leaderstats folder of a player. I wanted to use RebirthStore:Increment(1, defaultValue) in a DataStore2 script. I've created this and it keeps saying Player is not a valid member of Players. Basically i need help in designing a way to define players in this script.
local Player = game:GetService("Players"):GetPlayers() game.Players.Player:WaitForChild("PlayerGui").ScreenGui.Frame.TextButton.MouseButton1Down:Connect(function(player) local RebirthStore = DataStore2("Rebirths", player) local Player = game:GetService("Players"):GetPlayers() local ItemStore = DataStore2("Items", player) local RebirthStore = DataStore2("Rebirths", player) local CashStore = DataStore2("Cash", player) local TotalStore = DataStore2("Total", player) for p in ipairs(Player) do if Player.leaderstats.Cash.Value >= 14 then RebirthStore:Increment(1, defaultValue) CashStore:Set(0) ItemStore:Set(0) script.Parent.Parent.Visible = false elseif Player.leaderstats.Cash.Value <= 14 then script.Parent.Text = "Cant Afford!" script.Parent.TextColor3 = Color3.fromRGB(255, 0, 0) wait(1) script.Parent.Text = "Rebirth?" script.Parent.TextColor3 = Color3.fromRGB(85, 0, 127) end end end)
Your problem is that u don't use game.Players.Player if Player is a variable! Use game.Players[Player] If thats a script u don't use PlayerGui on it