#What did I do wrong here to get this error msg? (could be a lot)
1 messages · Page 1 of 1 (latest)
I might be very wrong, but i assume gui will be nil, since it can't find PlayerGui, since its deleted?
But to be honestly, thats pretty bad approach.
I dont think so cuz a dif script that uses PlayerRemoving and PlayerGui works
but ur prob right about the Gui being nil just dont know how to fix
02:33:41.077 Disconnect from 127.0.0.1|60746 - Studio
02:33:41.079 nil - Server - Script:6
02:33:41.080 ServerScriptService.Script:7: attempt to index nil with 'FindFirstChild' - Server - Script:7
players.PlayerRemoving:Connect(function(ply: Player)
local gui = ply:FindFirstChild("PlayerGui")
print(gui)
local Inv = gui:FindFirstChild("InventoryScreen")
print(Inv)
local Frame = Inv:FindFirstChild("InventoryFrame")
print(Frame)
local Label = Frame:FindFirstChild("InventoryText")
print(Label)
local tex = Label.Text
print(tex)
end)
So yes, the gui will be deleted first than trigger the PlayerRemoving
I swtiched player:findfirstchild("PLayerGui") to player.PlayerGui and got a dif error msg saying "playergui is not a valid member ot my player"
this script works tho
Yea, i think maybe youre "lucky" enough, to catch it, before it getting deleted.
But as i said, this isn't the best approch.
I would create a Player table for it. And if player edit the text, or idk what this is, then save it to Server Player table.
im beginner idk what a player table is 🙏
waitforchild
THIS IS NOT BEST APPROACH!!!
But this is just a template, showing what kind of Player table is.
local playerData = {}
game.Players.PlayerAdded:Connect(function(ply)
playerData[ply.UserId] = {
speed = 0 -- idk what you need
}
local textValue = ply:WaitForChild("PlayerGui"):WaitForChild("thistext")
textValue.Changed:Connect(function()
playerData[ply.UserId].speed = textValue.Text
end)
end)
who's table?
Already tried that got the same error msg but for wait for hold
Thank you 🙏
Im bit confused by your question?
Its just a normal table which is pretty good to use also for Player Table. (I would do of course different ways, but showing small things, how things works)