Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Collectible not changing imagetransparency of ui when touched?

Asked by 3 years ago
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

0
is this a LocalScript Gmorcad12345 434 — 3y
0
Yes this is a localscript shipleydog2 -3 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago

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
0
This still doesn't work shipleydog2 -3 — 3y
Ad

Answer this question