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

How do i fix my character being frozen when i clone its body parts?

Asked by 3 years ago

My character always freezes when i run the "else" function

local UserInputService = game:GetService("UserInputService")

local shiftKeyL = Enum.KeyCode.LeftShift
local shiftKeyR = Enum.KeyCode.RightShift

local function IsShiftKeyDown()
    return UserInputService:IsKeyDown(shiftKeyL) or UserInputService:IsKeyDown(shiftKeyR)
end

local function Input(input, gameProcessedEvent)
    if IsShiftKeyDown() then
        print("NA")
    else
        while wait(0.1) do
            local plr = game.Players.LocalPlayer
            local character = plr.Character

            local LeftArm = character["Left Arm"]:Clone()
            local RightArm = character["Right Arm"]:Clone()
            local LeftLeg = character["Left Leg"]:Clone()
            local RightLeg = character["Right Leg"]:Clone()
            local Torso = character.Torso:Clone()
            local Head = character.Head:Clone()

            LeftArm.Material = ("ForceField")
            RightArm.Material = ("ForceField")
            LeftLeg.Material = ("ForceField")
            RightArm.Material = ("ForceField")
            Torso.Material = ("ForceField")
            Head.Material = ("ForceField")

            LeftArm.Parent = game.Workspace
            RightArm.Parent = game.Workspace
            LeftLeg.Parent = game.Workspace
            RightLeg.Parent = game.Workspace
            Head.Parent = game.Workspace
            Torso.Parent = game.Workspace

            LeftArm.Position = character["Left Arm"].Position
            RightArm.Position = character["Right Arm"].Position
            LeftLeg.Position = character["Left Leg"].Position
            RightLeg.Position = character["Right Leg"].Position
            Head.Position = character.Head.Position
            Torso.Position = character.Torso.Position

            LeftArm.Orientation = character["Left Arm"].Orientation
            RightArm.Orientation = character["Right Arm"].Orientation
            LeftLeg.Orientation = character["Left Leg"].Orientation
            RightLeg.Orientation = character["Right Leg"].Orientation
            Head.Orientation = character.Head.Orientation
            Torso.Orientation = character.Torso.Orientation

            LeftArm.CanCollide = false
            RightArm.CanCollide = false
            LeftLeg.CanCollide = false
            RightLeg.CanCollide = false
            Head.CanCollide = false
            Torso.CanCollide = false

            LeftArm.Anchored = true
            RightArm.Anchored = true
            LeftLeg.Anchored = true
            RightLeg.Anchored = true
            Torso.Anchored = true
            Head.Anchored = true

            character["Left Arm"].Anchored = false
            character["Right Arm"].Anchored = false
            character["Left Leg"].Anchored = false
            character["Right Leg"].Anchored = false
            character.Torso.Anchored = false
            character.Head.Anchored = false
        end
    end
end

UserInputService.InputBegan:Connect(Input)
0
try setting the parent of the clones after youve set all the other properties. also another issue may be that this is running in a local script so this effect wont replicate to the server potatomay 20 — 3y
0
if youve previously anchored the character in a server script then that is most likely your problem. even though this script will unanchor you on client, player movement is replicated so you will still be frozen potatomay 20 — 3y
0
where should i put the script? IceInterception 0 — 3y
0
take the "else" part of your function and bind it to a RemoteEvent with a server script in ServerScriptService, and then fire the event with the script in this post potatomay 20 — 3y
0
and place the remote event in a replicated storage, such as ReplicatedStorage :) potatomay 20 — 3y

Answer this question