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

Part not cloning into correct Object?

ok so in my game i have it where it will make a "bluebarrel" and when it does it is supposed to put a "speedup" inside of it which works fine but it wont clone into the one that spawned it will clone into the one that is already in workspace,ignore the chance and powerupchance variables they are for later use

script:

workspace.ChildAdded:Connect(function(obj)
	if obj:IsA("UnionOperation") then
		if obj.Name == "BlueBarrel" then
			print("BlueBarrel Appeared")
			local Chance = math.random(1,5)
			local PowerupChance = math.random(1,5)
			local clone1 = game.ReplicatedStorage.SpeedUp:Clone()
			clone1.Parent = workspace
			clone1.Position = obj.Position
		end
	end
end)

3 comments

0

If SpeedUp is a part, set the CFrame instead of the Position. Vector3 has collision detection, so attempting to position a part with Position will make sure it doesn't clip through anything.

0

it is supposed to clip through items for a effect as if it was actually inside the barrel

0

cancollide is off on speedup but not barrel

1 answer

You are putting the speedup inside the workspace instead of the barrel. Here is the correct script:

workspace.ChildAdded:Connect(function(obj)
    if obj:IsA("UnionOperation") then
        if obj.Name == "BlueBarrel" then
            print("BlueBarrel Appeared")
            local Chance = math.random(1,5)
            local PowerupChance = math.random(1,5)
            local clone1 = game.ReplicatedStorage.SpeedUp:Clone()
            clone1.Parent = obj -- obj, not workspace
            clone1.Position = obj.Position
        end
    end
end)

1 comment

0

i forgot to mention that the barrel gets :Destroy()'ed so if i parent it to the barrel it will also be destroyed, tho i did try changing it to obj instead of workspace but it still did the same thing

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