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

How to clone object but constantly keep changing it's properties?

Hello there, I have a script here where it's supposed to clone itself BUT continously update it's properties everytime it is cloned, like in this script where it's numbers add everytime it is cloned along with it's position, however I do not know on how to approach this and it does not seem to work, how do I remedy this?

local RS = game:GetService('ReplicatedStorage')
local AdditionEvent = RS:WaitForChild('AdditionEvent')
local Block = game.Workspace.Block

AdditionEvent.OnServerEvent:Connect(function(event)
	Block:Clone()
	Block.CFrame = Block.CFrame * (0,4,0)
        Block.SurfaceGui.TextLabel.Text +=1
end)

1 comment

0

You are trying to set the CFrame of the block that is in the workspace, and not the cloned one.

1 answer

✓ Accepted answer

You would want to put the Cloned Block into a Variable as i think you cant access the Cloned block if you dont also you forgot to place the cloned block in workspace and you also need to have a currentNumber or it would add Block.SurfaceGui.TextLabel.Text as 0 to 1 then it would add 1 to 0 again after it cloned again like this

local RS = game:GetService('ReplicatedStorage').Remotes
local AdditionEvent = RS:WaitForChild('AdditionEvent')
local Block = game.Workspace.Block
local CurrentNumber = 1
local CurrentCFrame = Block.CFrame
AdditionEvent.OnServerEvent:Connect(function(event)
	local ClonedBlock = Block:Clone()
	ClonedBlock.Parent = workspace
	CurrentCFrame = CurrentCFrame * CFrame.new(0,4,0)
	ClonedBlock.CFrame = CurrentCFrame
	CurrentNumber = CurrentNumber + 1
	ClonedBlock.SurfaceGui.TextLabel.Text = CurrentNumber
end)

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