Hello there ?????. I have a problem triggering the touch event. I am making a parabolic arc using a part (see code:)
local Part1 = script.Parent.Part1 function getXVal(a, b, c, d, Yval) return math.asin(Yval/a)*(1/b) end wait(1) print(Part1.Timer.Value) Part1.Timer.Value = 0 print(math.round(Part1.Position.Y) > 0) repeat wait() Part1.Position = Vector3.new(0,math.abs(30.5*math.sin((math.pi/44)*(5*Part1.Timer.Value+getXVal(30.5, math.pi/44,0,0,8.5)))),5*Part1.Timer.Value) until math.round(Part1.Position.Y) == 0 Part1.Timer.Value = 0
if you are wondering what Part1 is, its the part I am controlling in this code. Inside the part contains a script and a number value called "Timer" and this is the code (changes the x value as if its in a graph)
while wait() do script.Parent.Timer.Value += 0.1 end
I also have a part 2 code:
script.Parent.Touched:Connect(function(hit) if hit.Name == "Part1" then hit:Destroy() end end)
This code contains the touch event which doesn't seem to be working. If you have any ideas to fix it, please tell me
Alright guys, looks like I found out another way to solve my problem. You don't need the touch event. What I did was I kept waiting till Part1's z-coordinate and ordinate passed Part2's z-coordinate and ordinate. Here is the code:
local Part1 = workspace:WaitForChild("Part1") local debounce = false while wait() do if math.round(Part1.Position.Z) >= math.round(script.Parent.Position.Z) and math.round(Part1.Position.Y) <= math.round(script.Parent.Position.Y) and Part1.Timer.Value > 0 then if debounce == false then debounce = true Part1.Reflect.Value = not Part1.Reflect.Value wait(1) debounce = false end end end