Touch event dosent always detect, is there i better way to do that?

touch event dosent always detect, is there i better way to do that?

script:

TweenService = game:GetService(“TweenService”)
local OffTG = true

script.Parent.TouchEnded:Connect(function(hit)
OffTG = true
print(“off”)

end)
script.Parent.Touched:Connect(function(hit)
OffTG = false
local tween = TweenService:Create(
hit.Parent.Bottom,
TweenInfo.new(30, Enum.EasingStyle.Linear),
{ Color = Color3.fromRGB(86, 66, 54) }
)
local tween2 = TweenService:Create(
hit.Parent.Top,
TweenInfo.new(30, Enum.EasingStyle.Linear),
{ Color = Color3.fromRGB(204, 142, 105) }
)
if hit.Name == “Hitbox” then

		print("on")
	hit.Parent.Holding.Changed:Connect(function()
		if OffTG == false then
		if hit.Parent.Holding.Value == false then

			if hit.Parent.UnFlipped.Value == true then
                 hit.ProximityPrompt.Enabled = true
			
				tween:Play()
				tween2:Play()
				hit.Sizzle:Play()


			end
		else
				hit.ProximityPrompt.Enabled = false
			tween:Pause()
			tween2:Pause()
			hit.Sizzle:Stop()
			end
			end
			end)
	end


end)

Could you describe what is is that you’re trying to do? What is script.Parent? What should happen when it gets touched and before it gets touched?

its for a grill script, there is a script that lets you move a patty on the grill and this scripts is supposed to detect when the patty is on but sometimes it does not fire properly when it moves too fast or simply just placing there and not firing

How do you put the patty on the grill? If you assign a button to “placing down the patty” then you can just paste your code inside that instead of the touch event. If you physically have to lift and drop the patty onto the grill, I recommend using a detection area on top of the grill and checking every second if the patty is inside that area.

For that, create a part that’s just above the grill (where the patties could be) and use a loop that checks every second if a patty is inside that part.

To get the patties inside that part:

patty moving script is really just clicking on the part and then the parts cframe updates with the mouse cframe everytime it changes. im new to this kind of stuff, what do you think i should use?

In that case, use the second option

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.