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

Why won't my textlabel's text change or disappear?

I am trying to make a script where Text will appear when you hit a winpad after an obby saying +10 points!, but For whatever reason it seems to not work. Is there a setting that could be on the text that makes it so it cannot change? The signals for "working" and "done" also work.

Here is what my StarterGui Folder looks like Here

db = false
script.Parent.Touched:connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") then
        local add = game.StarterGui.Add.Points
        if db == false then
            print("working")
            db = true
            add.Text = "+10 points"
            add.TextTransparency = 0
            wait(3)
            add.TextTransparency = 1
            add.Text = "+0 points"
            db = false
            print("done")
        end
    end
end) 

4 comments

0

you need to use players startergui

0

also local or serverside?

0

Do you think I need to use a LocalScript for this code? I don't want the changing message to appear for everyone, just the player

0

lemme answer

2 answers

✓ Accepted answer

StarterGui is named startergui for a reason. its the gui you get when you just join the game. So do this:

db = false
script.Parent.Touched:connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") then
        local add = game.Players[hit.Parent.Name].PlayerGui.Add.Points
        if db == false then
            print("working")
            db = true
            add.Text = "+10 points"
            add.TextTransparency = 0
            wait(3)
            add.TextTransparency = 1
            add.Text = "+0 points"
            db = false
            print("done")
        end
    end
end) 

And yes this will work. DuckyRoblox's script was much longer and chunkier so use this.

For this I would use local script 100% so first heres your script so we would need to define player cause startergui doesnt control anything in live game so we gotta define PlayerGui

db = false--debounce
script.Parent.Touched:connect(function(hit)--Function of touched
local player = game.Players.LocalPlayer--Get player Locally
local plrgui = player:WaitForChild("PlayerGui")--Gets playergui
    if hit.Parent:FindFirstChild("Humanoid") then --Checks if humanoid touched
        local add = plrgui.Add.Points-- defines gui for player
        if db == false then--If db = false then do
            print("working")--Prints working
            db = true--debounce = true
	    add.Visible = true--Makes text visible just incase it wasn't visible
            add.Text = "+10 points" --Makes text that
            add.TextTransparency = 0--makes transparency 1 Visible
            wait(3)--debounces wait time
            add.TextTransparency = 1--Makes transparency 0 Invisible
            add.Text = "+0 points"--Makes text that
            db = false --Makes db = false
            print("done") --Prints done
        end--ends debounce
    end--Ends hit statement
end) --Ends Function

Ok so basically I explained most of it and the problem accept if helps

1 comment

0

That does look like a great solution but when i tested it I got an error saying "15:06:31.731 - Workspace.WinPad.Added:4: attempt to index nil with 'WaitForChild'"

This discussion is preserved as it was. New answers, comments, and votes are closed.