So I have yet another problem: there is a folder in my player called “Values”, but the game does not recognize that it is there, and gives me an error. This completely breaks my game, so any help would be appreciated! If you need more info, just let me know.
The error output is: "Values is not a valid member of Player “Players.Noobzilla1207”.
Here is the part of the Script with the problem:
task.spawn(function()
while task.wait(1) do
if player.Values.SentTo.Value ~= nil then
local dmg = 20
player.Values.SentTo.Value.Health.Value = math.max(player.Values.SentTo.Value.Health.Value - dmg, 0)
if player.Values.SentTo.Value.Health.Value == 0 then
remotes.StopDamaging:FireServer()
destroyDrop(player.Values.SentTo.Value)
end
end
end
end)
Here is the script that gives the value to the player (its kinda long sorry):
local RunService = game:GetService("RunService")
local PlayersService = game:GetService("Players")
local MF = workspace.MainFolder_Workspace
local PPs = MF.PlayerPets
local drops = MF.Drops
local DataStoreService = game:GetService("DataStoreService")
local petsData = DataStoreService:GetDataStore("-petInventoryE")
-- //
game:GetService("Players").PlayerAdded:Connect(function(PlayerWhoAdded)
local backpackFolder = Instance.new("Folder")
backpackFolder.Name = "OwnedPets"
backpackFolder.Parent = PlayerWhoAdded
local PetsFolder = Instance.new("Folder")
PetsFolder.Name = PlayerWhoAdded.Name
PetsFolder.Parent = PPs
for _, v in pairs(script.PlayerData:GetChildren()) do
v:Clone().Parent = PlayerWhoAdded
local CS = PlayerWhoAdded:WaitForChild("ActionValues"):WaitForChild('CurrentInventorySpace') -- Current Pet Storage
local UserId = PlayerWhoAdded.UserId
local success, data = pcall(petsData.GetAsync, petsData, UserId)
if success and data then
for i, OldData in pairs(data) do
local n = Instance.new('StringValue')
n.Name = OldData
n.Parent = backpackFolder
n.Value = ""
CS.Value += 1 -- Adds An Inv Slot for Each Pet
end
local PlayerGUI = PlayerWhoAdded:WaitForChild("PlayerGui")
wait(2)
game:GetService("ReplicatedStorage").ServerEvents.reloadData:FireClient(PlayerWhoAdded,"petsLoading")
end
end
end)
game:GetService("Players").PlayerRemoving:Connect(function(Player)
local DataToSave = {}
local UserId = Player.UserId
for _,EachValue in pairs(Player.OwnedPets:GetChildren()) do
table.insert(DataToSave,EachValue.Name)
end
local Success,errorMessage = pcall(petsData.UpdateAsync, petsData, UserId, function()
return DataToSave
end)
if not Success then
warn("Pets Data Could Be LOST! - " .. errorMessage)
end
if PPs:FindFirstChild(Player.Name) then
PPs:FindFirstChild(Player.Name):Destroy()
end
end)
game:BindToClose(function()
if not RunService:IsStudio() then
for _,LocalPlayer in pairs(PlayersService) do
local DataToSave = {}
local UserId = LocalPlayer.UserId
for _,EachValue in pairs(LocalPlayer.OwnedPets:GetChildren()) do
table.insert(DataToSave,EachValue.Name)
end
local Success,errorMessage = pcall(petsData.UpdateAsync, petsData, UserId, function()
return DataToSave
end)
if not Success then
warn("Pets Data Could Be LOST! - " .. errorMessage)
end
end
end
end)
game.ReplicatedStorage.Remotes.PurchaseDoor.OnServerInvoke = function(player, door)
local serverDoor = workspace.MainFolder_Workspace.Doors:FindFirstChild(door.Name)
if serverDoor then
if player.leaderstats.ECoins.Value >= serverDoor.Price.Value then
if not player.Areas:FindFirstChild(serverDoor.Name) then
player.leaderstats.ECoins.Value -= serverDoor.Price.Value
local doorVal = Instance.new("StringValue")
doorVal.Name = serverDoor.Name
doorVal.Parent = serverDoor.Parent
return true
end
else
return false
end
end
end
game.ReplicatedStorage.Remotes.StopDamaging.OnServerEvent:Connect(function(player)
player.Values.SentTo.Value = nil
local CPPs = PPs[player.Name]
if #CPPs:GetChildren() > 0 then
local pet = CPPs:FindFirstChildOfClass("Model")
pet.Attack.Value = nil
end
end)
for _, drop in pairs(drops:GetDescendants()) do
if drop:IsA("Model") then
drop.Health.Value = drop.MaxHealth.Value
drop.ClickDetector.MouseClick:Connect(function(player)
local CPPs = PPs[player.Name]
if #CPPs:GetChildren() > 0 then
local pet = CPPs:FindFirstChildOfClass("Model")
if player.Values.SentTo.Value == nil then
player.Values.SentTo.Value = drop
pet.Attack.Value = player.Values.SentTo.Value
elseif player.Values.SentTo.Value == drop then
player.Values.SentTo.Value = nil
pet.Attack.Value = player.Values.SentTo.Value
elseif player.Values.SentTo.Value ~= nil and player.Values.SentTo.Value ~= drop then
player.Values.SentTo.Value = drop
pet.Attack.Value = player.Values.SentTo.Value
end
end
end)
end
end
for _, door in pairs(workspace.MainFolder_Workspace.Doors:GetChildren()) do
door.ProximityPart.ProximityPrompt.Triggered:Connect(function(player)
if not player.Areas:FindFirstChild(door.Name) then
game.ReplicatedStorage.Remotes.PromptPurchaseDoor:FireClient(player, door)
end
end)
end
And lastly, here is proof showing that the “Values” folder is in my Player:
Sorry for the long reading!