I'm trying to implement a "pet" system where a pet model is parented to the character in the workspace. I'm trying to get the character of the script that is parented to the pet that is parented to the character. However, "Workspace" is printed not player name.

local character = script.Parent.Parent
local pet = script.Parent
local function attack(player, target)
print(character)

Attack function is hooked to a remote event that is fired from a local script. link to image of hierarchy: https://imgur.com/a/dB2GbLU

3 comments

0

well if the script is inside the character then for character you would just need script.Parent

0

script is inside pet which is inside character

0

can you post a picture of your hierarchy? (the explorer window)