local folder = workspace.Collectibles
for _,v in pairs(folder:GetChildren()) do
local Collectible = v
Collectible.Touched:Connect(function(hit)
Collectible.BrickColor = BrickColor.new("White")
Collectible.Transparency = 0.3
if Collectible.Name == "Collectible1" then
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
plr.PlayerGui.UI.Script1.ImageTransparency = 0
end
end)
end
COMMUNITY QUESTION
Collectible not changing imagetransparency of ui when touched?
1 answer
Hello, I don't really understand what you're trying to do but please try this. I added a guard clause so the codes below would only get executed when what hit Collectible is a player. Feel free to comment if it ends up not being what you are trying to accomplish.
local folder = workspace.Collectibles
for _,v in pairs(folder:GetChildren()) do
local Collectible = v
Collectible.Touched:Connect(function(hit)
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
if not plr then return end --guard clause
Collectible.BrickColor = BrickColor.new("White")
Collectible.Transparency = 0.3
if Collectible.Name == "Collectible1" then
plr.PlayerGui.UI.Script1.ImageTransparency = 0
end
end)
end
1 comment
0
This still doesn't work
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
is this a LocalScript
Yes this is a localscript