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

ok so, i tried finding the player model in workspace then tried cloning it?

Asked by 3 years ago

I didnt know how to approach it so i tried this, it gives me a error saying that plr is not a valid member of workspace, how can i achieve finding the player model through a script?

The script:

local Debounce = false
local plr = game.Players.LocalPlayer.Name
local Clone = game.Workspace.plr:Clone()

function onKeyPress(actionName, userInputState, inputObject)
    if userInputState == Enum.UserInputState.Begin then
        print("Cloned")
        Clone.Humanoid:Destroy()
        Clone.Parent = game.Workspace
        Clone.Position = game.workspace.plr.Position

    end

end

game.ContextActionService:BindAction("keyPressSpecialName", onKeyPress, true, Enum.KeyCode.Q)
game.ContextActionService:SetPosition("keyPressSpecialName", UDim2.new(.5,0,-.5,0))
game.ContextActionService:SetImage("keyPressSpecialName", "rbxassetid://73737626")



1 answer

Log in to vote
1
Answered by 3 years ago
Edited 3 years ago

line 2 and 3 wouldn't work You cant get a players character by doing

local plr = game.Players.LocalPlayer.Name
local Clone = game.Workspace.plr:Clone()

There's 2 other ways that would work

Try

local Clone = workspace:FindFirstChild(plr)

Or

local plr = game.Players.LocalPlayer.Character
local Clone = plr:Clone()

And line 10 wouldn't work either. For line 10 try

Clone:MoveTo(YourPositionHere)
Ad

Answer this question