after someone helped me with my other script in my simulator game, i tried making a "Delete Your Data" button. But now on line 4, its saying attempt to index local 'player' (a nil value) can someone help me?
local delete = game:GetService("ServerStorage")
script.Parent.MouseButton1Click:Connect(function(player)
delete:FindFirstChild(player.UserId).Parent = workspace
wait(1)
delete:FindFirstChild(player.UserId).Parent = delete
script.Parent.Parent.TextLabel.Text = "Deleted"
wait(1.5)
script.Parent.Parent.Visible = false
script.Parent.Parent.TextLabel.Text = "Are You Sure? This Will Delete All Your Data."
end)
my stats script:
local serverStorage = game:GetService("ServerStorage")
local datastore = game:GetService("DataStoreService"):GetDataStore("PlayerSave3")
game:GetService("Players").PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local strength = Instance.new("NumberValue")
strength.Name = "Strength"
strength.Value = 0
strength.Parent = leaderstats
local rebirths = Instance.new("IntValue")
rebirths.Name = "Rebirths"
rebirths.Value = 0
rebirths.Parent = leaderstats
local dataFolder = Instance.new("Folder")
dataFolder.Name = player.Name
dataFolder.Parent = serverStorage:WaitForChild("RemoteData")
local debounce = Instance.new("BoolValue")
debounce.Name = "Debounce"
debounce.Parent = dataFolder
local success, errormessage = pcall(function()
datastore:GetAsync(player.UserId)
end)
if success then
local LoadArray = datastore:GetAsync(player.UserId)
if LoadArray then
strength.Value = LoadArray[strength.Name]
rebirths.Value = LoadArray[rebirths.Name]
end
else
warn(errormessage)
end
player.CharacterAppearanceLoaded:Connect(function(character)
local humid = character:WaitForChild("Humanoid")
local bds = humid:WaitForChild("BodyDepthScale")
local bhs = humid:WaitForChild("BodyHeightScale")
local bws = humid:WaitForChild("BodyWidthScale")
local hhs = humid:WaitForChild("HeadScale")
local pbw = player:WaitForChild("Backpack"):WaitForChild("Weight")
local default1 = 0.5
local default2 = 16
local base = 250
local p1 = default1 + (strength.Value / base)
local s1 = default2 + (strength.Value / base)
bds.Value = p1
bhs.Value = p1
bws.Value = p1
hhs.Value = p1
humid.WalkSpeed = s1
strength:GetPropertyChangedSignal("Value"):Connect(function()
local p2 = default1 + (strength.Value / base)
local s2 = default2 + (strength.Value / base)
bds.Value = p2
bhs.Value = p2
bws.Value = p2
hhs.Value = p2
pbw.Handle.Size = Vector3.new(p2, p2, p2)
humid.WalkSpeed = s2
end)
end)
end)
game:GetService("Players").PlayerRemoving:Connect(function(player)
local lead = player:WaitForChild("leaderstats")
local str = lead:WaitForChild("Strength")
local reb = lead:WaitForChild("Rebirths")
local SaveArray = {}
SaveArray[str.Name] = str.Value
SaveArray[reb.Name] = reb.Value
local success, errormessage = pcall(function()
datastore:SetAsync(player.UserId, SaveArray)
end)
if not success then
warn(errormessage)
end
end)

12 comments
line 5 attempt to index a nil value
print(delete:FindFirstChild(player.UserId)) on line 5 and print(player.UserId) on line four to see to see if either are a nil value
i put delete:FindFirstChild(player.UserId) on line 5 and now its says same but on line 7
i tried putting parent the parent into workspace now its says same thing line 5
when you added those two prints what did it print? I might be a bit confusing so I'll edit my post to show you what I mean
edited. tell me what those values print when you press run. it'll still error, but this will help us know what's going wrong.
Player AlbertoMiAmigo2 UserId 268163689 nil i think its because you cant acces things from server storage want me to post the data store script?
Can you pls send me a screenshot of "268163689" in the serverstorage just so we can make sure it's there? also, maybe try delete:FindFirstChild(tostring(player.UserId)) instead
268163689 is my userid but okay are you talking about the data store? i will send both
https://prnt.sc/pbiym5 what it prints in output
the part i think your talking about https://prnt.sc/pbiyvi
hi did you ever get this working?