Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Output is giving me viva is not a valid... of workspace?

function onClick(click)
	local viva = click.Name
	game.Workspace.viva.HumanoidRootPart.CFrame = CFrame.new(Vector3.new(-1632, 1.5, -1888))
end
script.Parent.ClickDetector.MouseClick:connect(onClick)

My output is giving me viva is not a valid member of workspace. Please Help

1 answer

Because the MouseClick returns the Player who clicked, we can just access the player's Character, then the HumanoidRootPart.

function onClick(player) -- I shortened the playerWhoClicked to player.
    player.Character:WaitForChild("HumanoidRootPart").CFrame = CFrame.new(Vector3.new(-1632, 1.5, -1888))
end
script.Parent.ClickDetector.MouseClick:connect(onClick)

If you have any questions please leave a comment below. Thank you and I hope this will help.

This discussion is preserved as it was. New answers, comments, and votes are closed.