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

How i can make local variable work in this script?

	local Player = game.Players.LocalPlayer
	local UName = Player.Character.Name
	for i,v in pairs(workspace:GetChildren())do
		if v:IsA("Part") and v.Name == "Tape" then
		game.workspace.UName.HumanoidRootPart.CFrame = v.CFrame
		end
		end

I have error UName is not a valid member of workspace

3 comments

0

try game.Players.LocalPlayer.Name

0

Why don't you just user userID?

0

What are you trying to do? Are you trying to make an admin only room or something?

1 answer

✓ Accepted answer

What roblox think you are doing is finding an instance wiith the NAME UName to fix this just do

game.Workspace[UName].HumanoidRootPart.CFrame = v.CFrame

or just use the character Player.Character

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