Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Is there a reason this renderstepped is crashing studio?

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

2 comments

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.

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.

1 answer

✓ Accepted answer

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

This discussion is preserved as it was. New answers, comments, and votes are closed.