I am making a pet in Roblox Studio but I can't find a way to find the owner in workspace and follow them. I know how to make the value change once a player touches a part but not when the pet follows the person in workspace that has the same name as the StringValue value.

Script:

local Owner = script.Parent.Owner.Value

local OwnerFollow = game.Workspace:FindFirstChild(Owner)

while true do
	wait(5)
	print(OwnerFollow)
end

I tried to make it print the owners name but it would just come up with nil

How do I make it find the person in workspace with same value as the value and follow them.

6 comments

0

maybe do script.Parent.Owner.Name

0

Workspace.Bunny Morph.SnowBunny.Follow:7: attempt to index nil with 'Name'

0

Check if it exists before assuming it does.

0

still doesnt work... now it just prints nothing in the output

0

script.Parent.Owner is nil, check if it exists when you play it

0

still not working