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!
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
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?
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