Magnetic Powered Robot (I think)

“MEMEs the dna of the soul” - my friend
“we have Monsoon at home” - Someone on discord

Tbh I don’t know what to call this kinda mechanic but like… this robot here powered by magnetic core and no matter how much damage it sustains as long as the core still active it can always bring itself back together

7 Likes

this would be awesome in some RPG game, like dungeon quest. animation is smooth too

5 Likes

please do not make metal walls near with them or he get crushed by pushing in a wall!
be careful with them and do not bring nearly metal or magnetic items
Thanks! :slight_smile:

4 Likes

how much r u got lines of code? 325,000?

2 Likes

thats so frickin cool!!!

2 Likes

No more like 200 to 350 lines actually.

2 Likes

You could make an entire game:

Night of the Ever Living Dead!

:smiley:

1 Like

the only thing that can kill it is the void

1 Like

This magnetic-powered robot looks INSANELY GOOD AND COOL! Excellent job on it! It’s unique for Roblox! How long did it take to create? What will you use it in? It’s very cool!

1 Like

the dissemble and resemble function only use 80 lines of code

Here’s how I do this

first to get the disemble effect run a loop through the model then clone those part, apply collision and set the original part’s transparency to 1 you can make this trigger whenever the shield value go 0 I guess

for i,v in pairs(npc:GetChildren()) do -- run a loop to get all the parts
			if v:IsA("BasePart") and v.Name ~= "HumanoidRootPart" then -- clones the parts that isn't HumanoidRootPart
				v.Transparency = 1
				local new = v:Clone()
				for i,v in pairs(new:GetDescendants()) do -- destroy other thing else except SpecialMesh for the head
					if not v:IsA("SpecialMesh") then
						v:Destroy()
					end
				end
				new.Anchored = false
				new.CanCollide = true
				new.Parent = Folder
				new.CFrame = v.CFrame
				new.Transparency = 0
			end
		end

to assemble use tweenservice and move the part back into the place then after the tween completed, delete the fake part, and turn the orginal part’s transparency back to 0

for i,part in pairs(Folder:GetChildren()) do -- run a loop to get all the fake part
			for i, originalPart in pairs(npc:GetChildren()) do -- run a loop to get all the orginal part
				if originalPart.Name == part.Name then -- create a tween that put the part back to its orginal position if the name match
					local t = T:Create(part, TweenInfo.new(1, Enum.EasingStyle.Sine, Enum.EasingDirection.In), {CFrame = originalPart.CFrame})
					t:Play()
					task.spawn(function() -- this just do the magnetic beam thingy (Not essensual and can be delete)
						local att1 = Instance.new("Attachment", part)
						local att2 = Instance.new("Attachment", core)
						for i,v in pairs(BeamParticle:GetChildren()) do
							if v:IsA("Beam") then
								local new = v:Clone()
								new.Parent = part
								new.Attachment0 = att1
								new.Attachment1 = att2
							end
						end
					end)
					t.Completed:Connect(function() -- when the tween finish delete the fake part then set orginal part's transparency back to 0
						local new = SparkEffect:Clone()
						new.Parent = Folder
						new.CFrame = part.CFrame
						task.delay(.1, function()
							for i,v in pairs(new:GetDescendants()) do
								if v:IsA("ParticleEmitter") then
									v.Enabled = false
									task.delay(.1, function()
										new:Destroy()
									end)
								end
							end
						end)
						part:Destroy()
						originalPart.Transparency = 0
					end)
					task.wait(.2) -- add a little bit of delay so it look like the part is connecting back one by one
				end
			end
		end
Entire Code
local T = game:GetService("TweenService")

local npc = script.Parent
local hum = npc.Humanoid
local Anim = script.WalkAnim
hum.Animator:LoadAnimation(Anim):Play() -- loop running animation

local SparkEffect = game:GetService("ReplicatedStorage").RandomStuff.SparkEffect
local BeamParticle = game:GetService("ReplicatedStorage").RandomStuff.BeamParticle

local core = npc["Reactor Core Orb"].Inner

local oldLocation = npc.PrimaryPart.CFrame 

local Folder = Instance.new("Folder", workspace) -- make a new folder to keep all the parts

local IsSeperate = false -- toggle

while task.wait(5) do
	if IsSeperate then
		IsSeperate = false
		npc.PrimaryPart.CFrame = oldLocation
		-- for some reason whenever the part got clone the collision of the center piece such as torso will stuck inside the body of the original part 
		-- and push the model into a straight position which is why this line exists
		for i,part in pairs(Folder:GetChildren()) do -- run a loop to get all the fake part
			for i, originalPart in pairs(npc:GetChildren()) do -- run a loop to get all the orginal part
				if originalPart.Name == part.Name then -- create a tween that put the part back to its orginal position if the name match
					local t = T:Create(part, TweenInfo.new(1, Enum.EasingStyle.Sine, Enum.EasingDirection.In), {CFrame = originalPart.CFrame})
					t:Play()
					task.spawn(function() -- this just do the magnetic beam thingy
						local att1 = Instance.new("Attachment", part)
						local att2 = Instance.new("Attachment", core)
						for i,v in pairs(BeamParticle:GetChildren()) do
							if v:IsA("Beam") then
								local new = v:Clone()
								new.Parent = part
								new.Attachment0 = att1
								new.Attachment1 = att2
							end
						end
					end)
					t.Completed:Connect(function() -- when the tween finish delete the fake part then set orginal part's transparency back to 0
						local new = SparkEffect:Clone()
						new.Parent = Folder
						new.CFrame = part.CFrame
						task.delay(.1, function()
							for i,v in pairs(new:GetDescendants()) do
								if v:IsA("ParticleEmitter") then
									v.Enabled = false
									task.delay(.1, function()
										new:Destroy()
									end)
								end
							end
						end)
						part:Destroy()
						originalPart.Transparency = 0
					end)
					task.wait(.2) -- add a little bit of delay so it look like the part is connecting back one by one
				end
			end
		end
	else
		IsSeperate = true
		for i,v in pairs(npc:GetChildren()) do -- run a loop to get all the parts
			if v:IsA("BasePart") and v.Name ~= "HumanoidRootPart" then -- clones the parts that isn't HumanoidRootPart
				v.Transparency = 1
				local new = v:Clone()
				for i,v in pairs(new:GetDescendants()) do -- destroy other thing else except SpecialMesh for the head
					if not v:IsA("SpecialMesh") then
						v:Destroy()
					end
				end
				new.Anchored = false
				new.CanCollide = true
				new.Parent = Folder
				new.CFrame = v.CFrame
				new.Transparency = 0
			end
		end
	end
end
1 Like