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

Towers being created in cloning function that is in loop?

The is going as planned but if I execute the cloning function, it doesn't create one clone but several in a tower. And sometimes the clones will go to the Camera?

--Variables
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local Part = game.Workspace.Farm
--Move Part to Mouse Position Always
while true do
		Part.Position = mouse.Hit.p
		wait()
		
		mouse.Button1Down:connect(function()
		Part:Clone().Parent = game.Workspace
		Part.Anchored = true
		Part.Position = mouse.Hit.p 
		mouse.TargetFilter = game.workspace.Water
		wait(5)
		Part:Destroy()
		end)
		print(mouse.Target.Name)
		wait()
		mouse.TargetFilter = game.Workspace.Farm
end



4 comments

0

why are you cloning it twice?

0

bump

1

You put the clicking function in the loop too. :| That creates a new click-listener every time the loop repeats.

0

only is click on my mouse the function will be executed, i don't think the loops has anything involved.

1 answer

The problem is that you have been cloning it twice when the requirement for Lua is once. Also, if u run this script and click F9 or use the output window, u can see everything going wrong or right in ur script. If this answer helped accept it for answer, if not, ask for more details and I will gladly help. Good luck with your tower XD

2 comments

0

What? It's not in Lua. Also, it is not a requirement to clone something in your script. The output window doesn't know what you are doing, so it does not know something went wrong unless there is a syntax error.

0

yeah thats the thing, I meant when u want to clone something, you only clone it once, and roblox uses the script system called "Lua". and when u click F9 you can see more than just syntax errors XD

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