i have a script that looks for the player in the workspace using ‘game.Players.PlayerAdded:Connect’
inside my charvariable, the issue is that only runs when the player joins the game, and i have a seperate script that destroys() and clones() that script once the player unequips the tool, making the charvariable break.
is there any other way to mention the player in the workspace using a script (not local)?
based off of what i looked at on the creator documentation that is only for finding the player in game.Players
im trying to find the player’s model in the workspace.
correct me if im wrong but im supposed to put the entirety of my script in here? im not trying to make the entire code play when someone resets or joins. here’s more context for what im looking for:
the model im using this code for is a 2010s cellphone model im trying to fix, im specifically working on the GUI code. the GUI has a keypad and 5 message slots next to it that will display the Tool.Words.Value in the following code.
if (b.UserId == tonumber(number)) and charVariable:FindFirstChild("CellPhone") then
Tool.Words.Value = "Player busy" else
this part in the code specifically checks for when you type the userID (their phone number) into the keypad and if they already have the cellphone equipped (if they do, the cellphone model will be in their player model in the workspace) it displays the text “Player busy” in one of the message slots.
charVariable is supposed to be the players model in the workspace, and im trying to find a way to find their model consistently.
i was able to fix this by changing charVariable to search the workspace for the players name that is being called. then by doing that i FindFirstChild the charVariable to see if they have the cellphone in their inventory, if not, the call will continue, if they do, it will display the “Player Busy” message
local charVariable = workspace:FindFirstChild(b.Name) -- Searches workspace for player being called (b)
print("Player being called is" ..tostring(charVariable)) -- Displays player being called with name
if (b.UserId == tonumber(number)) and charVariable:FindFirstChild("CellPhone") then -- Searches if player has CellPhone in their model
Tool.Words.Value = "Player busy" -- If they do it displays "Player busy" in messages
elseif (b.userId == tonumber(number)) and (b.Character:FindFirstChild("Humanoid") ~= nil) then -- Calls normally if FindFirstChild did not find the CellPhone
Tool.Calling.Value = b.Backpack.CellPhone
Tool.Words.Value = "Calling " ..b.Name.. "..." -- Calls player