So the issue comes in when I'm trying to store the player into a variable. But for some reason when I go to check that variable immediately after I set it, I get the error that "PlayerGui is not a valid member of Model" which seems odd because if I recall correctly, it's supposed to return the player, not the player's character. Maybe there's something I'm missing. Here's the troublesome piece of code.
if game:GetService("Players"):GetPlayerFromCharacter(targetedCharacter):IsA("Player") then print("This is a player") local plrCheck = game:GetService("Players"):GetPlayerFromCharacter(targetedCharacter) if not plrCheck.PlayerGui:FindFirstChild("CursedGui") then
You're probably trying to find PlayerGui inside a player's character. PlayerGui is located in the player,player is located in the game.Players. Script must be something like this:
if game:GetService("Players"):GetPlayerFromCharacter(targetedCharacter) then print("This is a player") local plrCheck = game:GetService("Players"):GetPlayerFromCharacter(targetedCharacter) if not plrCheck.PlayerGui:FindFirstChild("CursedGui") then end end
The issue is fixed. I rewrote the function and double checked and it's working now. I probably made a spelling error that I missed though I don't know where as the part where the error occurred is still the same. This question can be closed.