Here is my code.
local enabled = true Player = script.Parent.Parent character = Player.Character mouse = Player:GetMouse() function onKeyDown(key) key = key:lower() if key == "t" then game:GetService("Chat"):Chat(Player.Character.Head, "Focus the mind, reflect upon yourself, and determine the goal.") local Left_Arm = Instance.new ("Part") local Right_Arm = Instance.new("Part") local Core = Instance.new("Part") local Left_Leg = Instance.new("Part") local Right_Leg = Instance.new("Part") Left_Arm.BrickColor = BrickColor.new("White") Left_Arm.Size = Vector3.new(1, 2, 1) Left_Arm.TopSurface = "Smooth" Left_Arm.BottomSurface = "Smooth" Left_Arm.Transparency = 0.7 Left_Arm.CanCollide = false Left_Arm.CFrame = Player.Character["Left Arm"].CFrame *CFrame.new(0, 0, 0) Left_Arm.Parent = workspace Right_Arm.BrickColor = BrickColor.new("White") Right_Arm.Size = Vector3.new(1, 2, 1) Right_Arm.TopSurface = "Smooth" Right_Arm.BottomSurface = "Smooth" Right_Arm.Transparency = 0.7 Right_Arm.CanCollide = false Right_Arm.CFrame = Player.Character["Right Arm"].CFrame *CFrame.new(0, 0, 0) Right_Arm.Parent = workspace Core.BrickColor = BrickColor.new("White") Core.Size = Vector3.new(2, 1.9, 1) Core.TopSurface = "Smooth" Core.BottomSurface = "Smooth" Core.Transparency = 0.7 Core.CanCollide = false Core.CFrame = Player.Character["Torso"].CFrame *CFrame.new(0, 0, 0) Core.Parent = workspace Left_Leg.BrickColor = BrickColor.new ("White") Left_Leg.Size = Vector3.new(1, 2, 1) Left_Leg.TopSurface = "Smooth" Left_Leg.BottomSurface = "Smooth" Left_Leg.Transparency = 0.7 Left_Leg.CanCollide = false Left_Leg.CFrame = Player.Character["Left Leg"].CFrame *CFrame.new(0, 0, 0) Left_Leg.Parent = workspace Right_Leg.BrickColor = BrickColor.new("White") Right_Leg.Size = Vector3.new(1, 2, 1) Right_Leg.TopSurface = "Smooth" Right_Leg.BottomSurface = "Smooth" Right_Leg.Transparency = 0.7 Right_Leg.CanCollide = false Right_Leg.CFrame = Player.Character["Right Leg"].CFrame *CFrame.new(0, 0, 0) Right_Leg.Parent = workspace local Weld = Instance.new("Weld") Weld.Part0 = Left_Arm --Weld.C0 = Left_Arm.CFrame:inverse() Weld.Part1 = character:FindFirstChild("Left Arm") Weld.Parent = character local Weld2 = Instance.new("Weld") Weld2.Part0 = Right_Arm --Weld2.C0 = Right_Arm.CFrame:inverse() Weld2.Part1 = character:FindFirstChild("Right Arm") Weld2.Parent = character local Weld3 = Instance.new("Weld") Weld3.Part0 = Core --Weld3.C0 = Core.CFrame:inverse() Weld3.Part1 = character:FindFirstChild("Torso") Weld3.Parent = character local Weld4 = Instance.new("Weld") Weld4.Part0 = Left_Leg --Weld4.C0 = Left_Leg.CFrame:inverse() Weld4.Part1 = character:FindFirstChild("Left Leg") Weld4.Parent = character local Weld5 = Instance.new("Weld") Weld5.Part0 = Right_Leg --Weld5.C0 = Right_Leg.CFrame:inverse() Weld5.Part1 = character:FindFirstChild("Right Leg") Weld5.Parent = character end end mouse.KeyDown:connect(onKeyDown)
Instead of the blocks connecting to the player's body like in build mode. Can anyone help?
The problem with this code is that by the time the LocalScript loads, the Character typically isn't. To fix this, we can employ the wait script-yielder.
As quoted from the wiki, RBXScriptSignal:
wait() | Pauses the script until the event is fired and returns any arguments the event returns.
So, we can logically interpret that what needs to be done is this:
character = Player.Character or Player.CharacterAdded:wait();
This should fix your problem. Just replace the previous Character definer with that code.