I made a script that is supposed to change the transparency of an ImageLabel named "Nut1" in StarterGui to 0 when a part named "NutGiver" is touched by the player. The script does not change the tranparency of this ImageLabel.
I wrote a few print statements to debug the code. It outputs: "NutGiver touched by player: BunjiBloxxer", then it prints: "ImageLabel transparency before change: 0.7", then "ImageLabel transparency set to 0", then "ImageLabel transparency after change: 0"
According to the output, the script should be working correctly but it isn't.
EDIT: I did some testing and it turns out the ImageLabel transparency does change to 0 after I touch the parts, but only after I die in game. Does anyone know why?
local ImageLabel = game.StarterGui.Nuts.Nut1
local NutGiver = script.Parent
NutGiver.Touched:Connect(function(part)
local player = game.Players:GetPlayerFromCharacter(part.Parent)
if player then
print("NutGiver touched by player: " .. player.Name)
print("ImageLabel transparency before change: " .. ImageLabel.ImageTransparency)
ImageLabel.ImageTransparency = 0
print("ImageLabel transparency set to 0")
print("ImageLabel transparency after change: " .. ImageLabel.ImageTransparency)
else
print("NutGiver touched by non-player object")
end
end)

1 comment
Thanks for this detailed answer! It worked perfectly