You forgot define character + you must do character.Parent
You literally quoted me defining the characterâŚ
i know its been 7 months and you probably know what he means now, but just in case you dont:
getting the character should ALWAYS be the following in a local script:
local player = game:GetService("Players").LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
note that you dont need to add the âorâ statement if the local script is in StarterCharacterScripts, since the script will have never loaded in before the character has.
basically what the âorâ statement does is, if player.Character = nil, then it will wait until the CharacterAdded event fires, and that event returns the character by default
Hello, thank you for attempting to solve this quite old post. This was not a local script, but rather a regular script. The problem is no longer relevant to me as I never did anything with the project anyways, but thanks for trying to solve it!
yeah i figured lol, also thats why i specifically said in a local script. in a server script you would probably get the players character by either searching for them in the workspace or getting it when the player joins via PlayerAdded
Nowadays I would probably do this
local Player = script.Parent.Parent.Parent -- Would go script > tool > backpack > player
this isnt a very good practice. instead, it should be one server script, that uses the game.Players.PlayerAdded event to get each player instance and then run the game logic that interacts with the player from there
I wouldnât use that code in a normal situation, but given the admittedly bad way I was scripting the tool this wouldâve been what I did back then
either i am misunderstanding, or theres a typo in your previous post? you said âNowadays I would probably do thisâ implying you would write that code if you were to try making this again.
Nowadays may have been the wrong wording, for the given situation back then the code I gave wouldâve likely been a solution
But today I would not use the system I tried to do back then
ah, i understand now, thanks for clearing that up
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.