You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? Keep it simple and clear!
I’m trying to make a script where when a player touches a brick, a part from Lighting is cloned and the clone part is placed in the workspace.
What is the issue? Include screenshots / videos if possible!
The issue is when I stand on the part, 8 parts generate instead of one.
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I’ve tried looking up tutorials and adding wait times. I’ve looked on the developer hub.
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild('Humanoid') then
wait(1)
local PartTwoClone = game.Lighting.PartTwo:Clone()
PartTwoClone.Parent = game.Workspace
end
end)
Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.
You don’t have a debounce, leading to touched firing and executing the same code many times per touch. Wait(1) won’t do anything as connections are asynchronous.
local debounce = false
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild('Humanoid') and debounce == false then
debounce = true
wait(1)
local PartTwoClone = game.Lighting.PartTwo:Clone()
PartTwoClone.Parent = game.Workspace
debounce = false
end
end)
You are touching it multiple times, wait(1) won’t help, you need to add debounce
local db = false
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild('Humanoid') and db ~= true then
db = true
local PartTwoClone = game.Lighting.PartTwo:Clone()
PartTwoClone.Parent = game.Workspace
wait(1)
db = false
end
end)