Proximity Prompt Value Update Help

Hello again! I am currently attempting to create a script where after a proximity prompt is triggered while holding a specific tool, the transparency of the drink part within the cup is changed to transparency = 0 (visible).

This is what I have so far but it doesn’t seem to work:

local Data = {
	["Milk"] = {
		Name = "Cup of Milk",
		Color = Color3.fromRGB(255, 255, 255),
	},
}

local ProximityPrompt = script.Parent

local Model = script.Parent:GetChildren()
for Index = 1, #Model do
	local self = Model[Index]
	if self:IsA("BasePart") then
		local _Data = Data[self.Name]
		self.Touched:Connect(function(Hit)
			if ProximityPrompt.Parent:IsA("Tool") then
				if ProximityPrompt.Triggered.Parent.Name == "Cup" then
					ProximityPrompt.Parent.Name = _Data.Name or "-"
					ProximityPrompt.Parent.Drink.Transparency = 0
					ProximityPrompt.Parent.Drink.Color = _Data.Color or Color3.fromRGB(255, 255, 255)
				end
			end
		end)
	end
end

Any help would be appreciated please and thank you!

Typo
if ProximityPrompt.Triggerted.Parent.Name == “Cup” then

1 Like
local Data = {
	["Milk"] = {
		Name = "Cup of Milk",
		Color = Color3.fromRGB(255, 255, 255),
	},
}

local ProximityPrompt = script.Parent

local Model = script.Parent:GetChildren()
for i,v in pairs(Model) do
if v:IsA("BasePart") then
local _Data = Data[v.Name]
if ProximityPrompt.Parent:IsA("Tool") then
local triggerConnection 
triggerConnection = ProximityPrompt.Triggered:Connect(function()
if ProximityPrompt.Parent.Name == "Cup" then
ProximityPrompt.Parent.Name = _Data.Name or "-"
ProximityPrompt.Parent.Drink.Transparency = 0
ProximityPrompt.Parent.Drink.Color = _Data.Color or Color3.fromRGB(255,255,255)
end
end)
end
end
end

Hmm I adapted the code to my own and it still doesn’t seem to want to make the part of the tool transparent when the prompt is activated.

Any errors you got in the output?

I received

22:26:06.539  Workspace.Master Culinary Database.Drink System.Boba.MILK.Milk System.BobaMilk.ProximityPrompt.MasterMilkSystem:32: Expected 'end' (to close 'do' at line 19), got <eof>; did you forget to close 'then' at line 25?

You forgot to close the function with end

Which function would the end be tacked onto?

Count how many functions there are in the script and close them in order
send the script here if you still can’t fix it

I believe you just add another end to the end of that script.

1 Like

Now the output has no more errors but when I tested it still didn’t seem to work here is the code now:

local Data = {
	["BobaMilk"] = {
		Name = "Boba Cup w/ Milk",
		Color = Color3.fromRGB(255, 255, 255),
	},
}

local ProximityPrompt = script.Parent

local Model = script.Parent:GetChildren()
for i,v in pairs(Model) do
	if v:IsA("BasePart") then
		local _Data = Data[v.Name]
		if ProximityPrompt.Parent:IsA("Tool") then
			local triggerConnection 
			triggerConnection = ProximityPrompt.Triggered:Connect(function()
				if ProximityPrompt.Parent.Name == "Boba Cup" then
					ProximityPrompt.Parent.Name = _Data.Name or "-"
					ProximityPrompt.Parent.Drink.Transparency = 0
					ProximityPrompt.Parent.Drink.Color = _Data.Color or Color3.fromRGB(255,255,255)
				end
			end)
		end
	end
end

So to confirm, you are using a Proximity Prompt in a tool?

No no, the prompt is in a model, the tool is external that you grab from somewhere else and bring to the model in order to “fill the cup with milk”

Oh ok. I guess I got confused there.

The most simplest thing you can try is using prints to see how far in the code it’s reaching since you aren’t getting errors.

1 Like