Log in to vote

Part that Runs Script when Stepped On Makes Infinite Clones, Why does it do that?

Asked by 16 days ago

I've been trying to solve this issue for many hours but I cannot seem to find a working solution. I have a script of a part (script.Parent) that when stepped on, would run a command that clones a part in ServerStorage with its own script. The problem is that when you step on the part it makes infinant clones which is an issue as it lags badly.

Code for Part:

local part = script.Parent
local playedAlready = nil

    if not playedAlready then
        -- Clones the part into Worksoace. 
        local lavaWall = game.ServerStorage.MyFolder.LavaWall
        local clonedPart = lavaWall:Clone()
        clonedPart.Parent = workspace.Levels11thru20
        clonedPart.Position =, 78, 800.5)
        if not clonedPart.Anchored then
            clonedPart.Anchored = not clonedPart.Anchored -- Sets to the opposite, personal pref.
        playedAlready = true

Answer this question