leaderstats is not a valid member of Player?
Yesterday i was working on a new game (my first one as you could probably tell)
but the code and everything worked fine yesterday and didnt change anything after that anymore, now that i want to continue working today i try running the game to make sure everything is still fine and i get met with the message: leaderstats is not a valid member of Player and i dont know whats wrong, could someone help? heh. again. Thanks!
01 | local DataStore = game:GetService( "DataStoreService" ) |
02 | local PointsData = DataStore:GetOrderedDataStore( "Points" ) |
04 | game.Players.PlayerAdded:Connect( function (player) |
05 | local points = PointsData:GetAsync(player.UserId) |
06 | local leaderstats = Instance.new( "Folder" ) |
07 | leaderstats.Name = "leaderstats" |
08 | local pointsValue = Instance.new( "IntValue" ,leaderstats) |
09 | pointsValue.Value = points |
10 | leaderstats.Parent = player |
11 | pointsValue.Name = "Strength" |
14 | game.Players.PlayerRemoving:Connect( function (player) |
15 | local strength = player.leaderstats.Strength.Value |
16 | PointsData:UpdateAsync(player.UserId, strength) |
20 | game.ReplicatedStorage.BuyItem.OnServerEvent:Connect( function (player,weight) |
21 | if player.leaderstats.Strength.Value > = weight.Price.Value then |
22 | player.leaderstats.Strength.Value = player.leaderstats.Strength.Value - weight.Price.Value |
23 | local newWeight = weight:Clone() |
24 | local oldWeight = player.Backpack:FindFirstChildOfClass( "Tool" ) or player.Character:FindFirstChildOfClass( "Tool" ) |
26 | newWeight.Parent = player.Backpack |