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

[SOLVED]How to delete a part and still be able to clone it?

I've got a script that clones a glowing arm shaped brick around the players right arm, with an electric effect, and a mesh to make it look more like an arm.

Inside of the arm, there is a script named Deadly, the script fires a function when touched, to spread the electricity effect from the targets legs, to the head, sapping more and more hp, until the target dies. After the target dies, the brick on the players arm is removed.

It works amazing, turned out just the way I wanted it to, but when I go to use it again, all I get is the brick, without the mesh or the effect, and the OnTouched event no longer works.

Any suggestions?

Script that summons the block to the player's arm, it is a local script inside of the starter pack:

local Player = game.Players.LocalPlayer
local char = Player.Character  
local mouse = Player:GetMouse() 
local lastUse = 0;
local rarm = game.ServerStorage:WaitForChild("RArm"):clone()

local function onKeyDown(key) 
    local Key = key:lower()
    if key == "z" and  tick()-lastUse > 1  then 
        lastUse = tick(); 
	                local a = Instance.new("Sound")
                       a.SoundId = "http://www.roblox.com/asset/?id=157325701"
                       a.Parent = rarm
                       a.Volume = 2
                       a:play()
					
					if rarm ~= nil then
						local rarmweld = Instance.new("Weld")
						rarmweld.Parent = rarm
						rarmweld.Part0 = rarmweld.Parent
						rarmweld.Part1 = char:findFirstChild("Right Arm")
						rarmweld.C1 = CFrame.new(0, 0, 0)
						rarm.Parent = char
					end
					
	
           game:GetService("Chat"):Chat(Player.Character.Head, "Sendo Ripple Overdrive!")


     


         
 

        
    end
end


mouse.KeyDown:connect(onKeyDown)

Script called Deadly, that is inside of the brick cloned to the player:

db = true

function onTouched(hit)
	if db == true then
		db = false
		local human = hit.Parent:findFirstChild("Humanoid")
		if (human ~= nil) then
			human.Health = human.Health - script.Damage.Value 
			human.Sit = true
		local rekt = script.Parent.Effect:Clone()
		rekt.Parent = human.Parent.Torso
		end
		wait(.1)
		db = true
		wait(1)
		human.Health = human.Health - 7
		local rekt2 = script.Parent.Effect:Clone()
		rekt2.Parent = human.Parent:FindFirstChild("Left Arm")
		wait(1)
		human.Health = human.Health - 7
		local rekt3 = script.Parent.Effect:Clone()
		rekt3.Parent = human.Parent:FindFirstChild("Right Arm")
		wait(1)
		human.Health = human.Health - 7
		local rekt4 = script.Parent.Effect:Clone()
		rekt4.Parent = human.Parent:FindFirstChild("Right Leg")
		wait(1)
		human.Health = human.Health - 7
		local rekt5 = script.Parent.Effect:Clone()
		rekt5.Parent = human.Parent:FindFirstChild("Left Leg")
		wait(10)
		human.Health = human.Health - 100
		local rekt6 = script.Parent.Effect:Clone()
		rekt6.Parent = human.Parent:FindFirstChild("Head")
		
		wait(2)
		script.Parent:Remove()
		
		
			
		
	end
end


script.Parent.Touched:connect(onTouched)

P.S Yes, I know that KeyDown is deprecated. Please do not counsel me on changing it, I will change it when I have to, thanks,

6 comments

0

Make a "prefab" in ServerScriptService or ReplicatedStorage to clone.

0

Oh that's cool, I didn't know you could do that with roblox. Uh.. I have 0 experience with prefabs though, could you point me in the correct direction? Like a tutorial or some webpage. I found very little about roblox prefabs when I looked them up

0

btw you can just use a for i,v in pairs do loop instead of writing every body part out

0

Cut it and paste it kek

0

I used prefab loosely. What I meant was save the part/model in a storage service and clone it from there.

0

i already have the part in ReplicatedStorage, same problem

1 answer

There are two good solutions to this problem.

The first: Clone the part, and then make clones of that clone. Example:

local clone = part:Clone()
local clone2 = clone:Clone()

The second: Store the part in Replicated/Server Storage, and clone it from there. Example:

local part = game.Replicated.Storage.Part
local clone = part:Clone()

1 comment

0

Neither of those two solutions worked. .-.

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