local UIS = game:GetService("UserInputService")
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
UIS.InputBegan:Connect(function(Input,isTyping)
if isTyping then return end
if Input.KeyCode == Enum.KeyCode.E then
local clone = char:Clone()
print("working")
clone.HumanoidRootPart.CFrame = char.HumanoidRootPart.CFrame * CFrame.new(0, 0, 3)
clone.Parent = workspace
end
end)
local playerToClone = ""
local function clone(char)
character.Archivable = true
local cloned = character:Clone()
character.Archivable = false
return cloned
end
local characterClone = clone(game.Players[playerToClone].Character)
characterClone.Parent = game.Workspace
Since its a local script, you dont need to call the PlayerAdded and CharacterAdded events. You can easily get the player and character by just making variables.
Here is your updated code:
local UIS = game:GetService("UserInputService")
local Players = game:GetService("Players")
local plr = Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local hrp = char:WaitForChild("HumanoidRootPart")
UIS.InputBegan:Connect(function(input, typing)
if typing then
return
end
if input.KeyCode == Enum.KeyCode.E then
local clone = char:Clone()
clone.Archivable = true
clone:WaitForChild("HumanoidRootPart").CFrame = hrp.CFrame * CFrame.new(3.5, 0, -1.2) * CFrame.Angles(0, math.rad(90),0)
clone.Parent = workspace
print("working!")
end
end)
local userInput = game:GetService("UserInputService")
local players = game:GetService("Players")
local player = players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
userInput.InputBegan:Connect(function(Input, isTyping)
if isTyping then return end
if Input.KeyCode == Enum.KeyCode.E then
character.Archivable = true
local clone = character:Clone()
clone.PrimaryPart.CFrame *= CFrame.new(0, 0, 3)
clone.Parent = workspace
end
end)