Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How i can make local variable work in this script?

Asked by
AIexR32 11
5 years ago
    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

0
try game.Players.LocalPlayer.Name boshjio15854 15 — 5y
0
Why don't you just user userID? jordysboy 53 — 5y
0
What are you trying to do? Are you trying to make an admin only room or something? 123nabilben123 499 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

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

Ad

Answer this question