Hello! I just started scripting yesterday, so this may be a semi-easy question to answer. Either way, I appreciate the help :)
I am trying to create a part "floor" by stepping on a part "step", which I have been successful in. The issue comes where the script continues to make the same part repeatedly for every touch on "step". I have tried two different ways to script it over the past few days and have consulted a large handful of videos, but can not get a solution.
Below is what I currently have scripted, trying to use a variable(I believe that's what it's called) to no longer allow it to create more blocks after "step" has been touched once (Untouched = Untouched + 1). It did not work.
local Untouched = 1
if Untouched == 1 then
game.Workspace.Step.Touched:Connect(function()
print("cp1")
local Floor = Instance.new("Part", game.Workspace)
print("cp2")
Floor.Size = Vector3.new(5,2,3)
print ("cp3")
Floor.Anchored = true
print("cp4")
Floor.Position = Vector3.new(0,1,-54.5)
print("cp5")
Floor.Color = Color3.new(0.639216, 0.635294, 0.647059)
print("cp6")
Floor.Material = Enum.Material.WoodPlanks
print("cp7")
Untouched = Untouched + 1
print("end?")
end)
end
I have tried using the connection:disconnect option listed on the roblox help website but had no luck from their explanation figuring out how to use it. If anyone has any tips or tricks on what to do to stop "floor" from spawning more than once, I would be eternally grateful.

1 comment
You need to add the if statement in the touch function so it can check once its touched