Starting clean
Before we go any further, it always helps to clean up our code a bit before trying to debug it. Sometimes you'll even find yourself fixing the bug as you clean it. This can be done simply with the proper use of line indentation, local variables when needed, and organization. I'll give an example of how this can be done as I walk through the problems.
Problems
1: The Remove function
The Remove function on line 19 of your script not being called correctly. In fact, it's a syntax error. An honest mistake or typo everyone goes through at some point, but your entire program won't even run if something is syntactically incorrect.
2: Functions
You have 2 functions given the same variable name: 'touch'. Lua reads code from top to bottom, left to right, and creating a function with the exact same name as one above it, will overwrite it with that new value. Making the one above it completely useless.
3: Variables
Proper use of your variables. This isn't technically an error, but makes your program extremely prone to causing one if you're not careful. The 'boom' variable you created can be referenced instead of indexing the workspace or game model to find the object you created.
4: Object names / Variables
Variables / Object names are not the same. Creating a variable called "boom" will not name your newly created object that as well. The default name for a newly created part, is "Part". To name it something else, you can access it's "Name" property and set it a new value. However, this won't be necessary in this case given the explanation above about utilizing variables.
Final result
Here would be your revised code:
local boom = Instance.new("Part", workspace)
local activated = false
local function touch(part)
if activated then
return
end
activated = true
boom.CFrame= CFrame.new(234, 190.5, 96)
boom.Shape = 0
boom.BrickColor = BrickColor.new("Bright Yellow")
boom.Transparency = 0
boom.Anchored = true
boom.CanCollide = false
for i = 1, 100 do
boom.Size = Vector3.new(i,i,i)
boom.CFrame = CFrame.new(234, 190.5, 96)
wait(0.5)
end
activated = false
end
boom.Touched:connect(touch)
Hope it helped. Let me know if you have any questions.
3 comments
your probably gonna get the accept for a detail answer :cry:
You just taught me a lot. I knew I should have used CFrame as well as debounce, but I was lazy. Thanks for teaching me a lot. Your revision didn't work, but you gave me enough info to possibly work on it some more.
Oh that's weird, worked for me :p. Anyway, glad that it helped!