View difference between Paste ID: 4x62KZqH and G5mhmh9S
SHOW: | | - or go back to the newest paste.
1
local player = game.Players.LocalPlayer
2
local mouse = player:GetMouse()
3
4
m1 = Instance.new("Model")
5
m1.Parent = nil
6
7
print(script.Name)
8
9
function onKeyPress(inputObject, gameProcessedEvent)
10
	print("Key")
11
	local key = inputObject.KeyCode
12
	if key == Enum.KeyCode.E then
13
		print("E")
14
		local target = mouse.Target
15
		if target.Parent:FindFirstChild("HumanoidRootPart") ~= nil then
16
			print("Switch")
17
			
18
			local hold = player.Character.HumanoidRootPart
19
20
			for i,v in pairs(player.Character:GetChildren()) do
21
				if v.Name ~= ("b") then
22
					v.Parent = m1	
23
				end
24
			end
25-
				v.Parent = player.Character
25+
26
				n = v:Clone()
27-
			--for i,v in pairs(m1:GetChildren()) do
27+
				if n.Name == ("HumanoidRootPart") then
28-
			--	v.Parent = target.Parent
28+
					n.CFrame = hold.CFrame
29-
			--end
29+
30-
			player.Character.Humanoid.NameDisplayDistance = 0
30+
				n.Parent = player.Character
31
			end
32
			wait(0.1)
33
			game.Workspace.Camera.CameraSubject = player.Character.Humanoid
34
		end
35
	end
36
end
37
38
game:GetService("UserInputService").InputBegan:connect(onKeyPress)