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

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

Asked by 4 years ago
Edited 4 years ago

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) 
0
you need to use players startergui DuckyRobIox 280 — 4y
0
also local or serverside? DuckyRobIox 280 — 4y
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 Buthter 6 — 4y
0
lemme answer DuckyRobIox 280 — 4y

2 answers

Log in to vote
0
Answered by 4 years ago

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.

Ad
Log in to vote
0
Answered by 4 years ago

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

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'" Buthter 6 — 4y

Answer this question