Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Collectible not changing imagetransparency of ui when touched?

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

2 comments

0

is this a LocalScript

0

Yes this is a localscript

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.