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

Roblox image labels not updating?

Asked by
2mania 14
2 years ago
Edited 2 years ago

When I try collect the badge the image label is suppost to turn green after you get it here is a video showing the bug here is the code that turns the label green

script.Parent.Touched:Connect(function(hit)
    local player = hit.Parent:FindFirstChild("Humanoid")
    if player then
        game.StarterGui.Waters.Frame.HydroWater["Hydro water"].BackgroundColor3 = Color3.new(0.34902, 1, 0)
    end
end)

1 answer

Log in to vote
0
Answered by 2 years ago

Your player variable is actually grabbing the character. With the character you can get the player and access their Gui information.

local Players = game:GetService("Players")
part.Touched:Connect(function(hit)
    local character = hit.Parent:FindFirstChild("Humanoid")
    if character then
        local player = Players:GetPlayerFromCharacter(character) -- getting the player
        if player then
            player.PlayerGui.Waters.Frame.HydroWater["Hydro water"].BackgroundColor3 = Color3.new(0.34902, 1, 0)
        end
    end
end)
0
Simple flame the script does not work should I make it a loop to check or should I just use a touch detector 2mania 14 — 2y
0
Sorry for the really late response but what error are you getting? The part.Touched should act as the touch detector. SimpleFlame 255 — 2y
Ad

Answer this question