Change touch connect to proximity prompt

hello. i am trying to change this touch connect to a proximity prompt. this is what i have tried but it does not work. how would i get this working? many thanks

script.Parent.Touched:Connect(function(hit)
if hit.Parent:IsA(“Tool”) then
if hit.Parent.Name == “Empty Milkshake Glass” then
if hit.Parent.Value.Value == 4 then
if hit.Parent.On.Value == false then
hit.Parent.On.Value = true
hit.Parent.Name = “Vanilla Milkshake”
script.Parent.Transparency = 0.3
wait(2)
hit.Parent.FullVan.Transparency = 0
hit.Parent.drinkVan.Disabled = false
hit.Parent.Straw1.Transparency = 0
hit.Parent.Straw2.Transparency = 0
script.Parent.Transparency = 1
end
end
end
end
end)

local prompt = script.Parent.ProximityPrompt

prompt.Triggered:Connect(function(hit)
if hit.Parent:IsA(“Tool”) then
if hit.Parent.Name == “Empty Milkshake Glass” then
if hit.Parent.Value.Value == 4 then
if hit.Parent.On.Value == false then
hit.Parent.On.Value = true
hit.Parent.Name = “Vanilla Milkshake”
script.Parent.Transparency = 0.3
wait(2)
hit.Parent.FullVan.Transparency = 0
hit.Parent.drinkVan.Disabled = false
hit.Parent.Straw1.Transparency = 0
hit.Parent.Straw2.Transparency = 0
script.Parent.Transparency = 1
end
end
end
end
end)

Try this:

--//Variables
local Part = script.Parent
local ProximityPrompt = Part.ProximityPrompt

--//Functions
Part.Touched:Connect(function(hit)
	if hit.Parent:IsA("Tool") and hit.Parent.Name == "Empty Milkshake Glass" and hit.Parent.Value.Value == 4 and not hit.Parent.On.Value then
		hit.Parent.On.Value = true
		hit.Parent.Name = "Vanilla Milkshake"
		Part.Transparency = 0.3
		
		task.wait(2)
		hit.Parent.FullVan.Transparency = 0
		hit.Parent.drinkVan.Disabled = false
		hit.Parent.Straw1.Transparency = 0
		hit.Parent.Straw2.Transparency = 0
		Part.Transparency = 1
	end
end)

ProximityPrompt.Triggered:Connect(function(player)
	local milkshakeGlass = player.Character and player.Character:FindFirstChild("Empty Milkshake Glass")
	
	if milkshakeGlass and milkshakeGlass.Value.Value == 4 and not milkshakeGlass.On.Value then
		milkshakeGlass.On.Value = true
		milkshakeGlass.Name = "Vanilla Milkshake"
		Part.Transparency = 0.3

		task.wait(2)
		milkshakeGlass.FullVan.Transparency = 0
		milkshakeGlass.drinkVan.Disabled = false
		milkshakeGlass.Straw1.Transparency = 0
		milkshakeGlass.Straw2.Transparency = 0
		Part.Transparency = 1
	end
end)

Player is the parameter for .Triggered.
Also, please format your code next time.

yes it worked! thank you very much! very appreciated!!!

No problem. If you have any more questions, feel free to ask.

1 Like