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

Is there a reason this renderstepped is crashing studio?

Asked by 8 years ago

Basically im using renderstepped to clone the character, and then remove anything other than parts. It then moves it to the position in which the player's character torso just left. Here is my code

run:BindToRenderStep("Gengeki",1,function()
                    print("hi")
                     local fake = player.Character:Clone()
                    for i,item in pairs(fake:GetChildren()) do
                        if item:IsA("Part") then
                            item.Transparency = .5
                            item.CanCollide = false
                        else
                            item:Destroy()
                        end
                    end
                    local cval = Instance.new("CFrameValue")
                    cval.Value = player.Character.Torso.CFrame
                    fake.Torso.Anchored = true
                    fake.Parent = game.Workspace.TempStorage
                    fake.Torso.CFrame = cval.Value
                    -- Where "from", where "to"
                    local inRoot = player.Character.HumanoidRootPart.CFrame
                    local outRoot = fake.HumanoidRootPart.CFrame
                    for _, part in pairs(fake:GetChildren()) do
    if part:IsA("BasePart") then
        -- Get original part relative to character:
        local correspond = player.Character[ part.Name ].CFrame
        -- Move me relative to my root:
        part.CFrame = outRoot * inRoot:toObjectSpace(correspond)

        end
    end
end)

        for i,v in pairs(game.Workspace.TempStorage:GetChildren()) do

    v:Destroy()
    wait()
end
repeat wait() until script.Parent.Parent.Gengeki.Value == false
run:UnbindFromRenderStep("Gengeki") 

Any advice helps, thanks

0
Comment out each section until you find just the section that cuases the code to crash, so you can look into that more closely. adark 5487 — 8y
0
Well, you are kind of doing a lot of cloning every render step. If your computer is less powerful, it could be that causing the issues. Otherwise, I blame some other code, because I really hope that's not the full thing. User#6546 35 — 8y

1 answer

Log in to vote
1
Answered by
yoshi8080 445 Moderation Voter
8 years ago

You're attempting to create to many parts and manipulate them.

Ad

Answer this question