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

Script not changing text of TextLabel?

Asked by 4 years ago

I'm trying to make a dialogue box that appears then starts talking but for some reason its not changing the text of the text label

local mouse = game.Players.LocalPlayer:GetMouse()
local txt = game.Players.LocalPlayer.PlayerGui.ScreenGui.Frame.TextLabel.Text

mouse.Button1Down:Connect(function()
    print("Mouse1Down")
    if mouse.Target.Name == "Hitbox" then
        print("Mouse1Down2")
        game.Players.LocalPlayer.PlayerGui.ScreenGui.Frame.Visible = true   
        txt = "Thank you so much for everything you have done dad!"
        wait(13)
        txt = "Happy Fathers Day! We really care about you!"
        wait(10)
        txt = "Thank you so much for raising us and being such a good parent!"
        wait(10)
        txt = " - Name"
        wait(5)
        game.Players.LocalPlayer.PlayerGui.ScreenGui.Frame.Visible = false
    else
        print("False")
        print("Target is " .. mouse.Target.Name)
    end
end)

0
Is it a localscript? TommyHArden 101 — 4y
0
Yes SillyDamien 11 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

I think you are using the variable wrong, instead of doing local txt = game.Players.LocalPlayer.PlayerGui.ScreenGui.Frame.TextLabel.Text You should set it to only local txt = game.Players.LocalPlayer.PlayerGui.ScreenGui.Frame.TextLabel So try this one, I corrected the script

local mouse = game.Players.LocalPlayer:GetMouse()
local txt = game.Players.LocalPlayer.PlayerGui.ScreenGui.Frame.TextLabel

mouse.Button1Down:Connect(function()
    print("Mouse1Down")
    if mouse.Target.Name == "Hitbox" then
        print("Mouse1Down2")
        game.Players.LocalPlayer.PlayerGui.ScreenGui.Frame.Visible = true   
        txt.Text = "Thank you so much for everything you have done dad!"
        wait(13)
        txt.Text = "Happy Fathers Day! We really care about you!"
        wait(10)
        txt.Text = "Thank you so much for raising us and being such a good parent!"
        wait(10)
        txt.Text = " - Name"
        wait(5)
        game.Players.LocalPlayer.PlayerGui.ScreenGui.Frame.Visible = false
    else
        print("False")
        print("Target is " .. mouse.Target.Name)
    end
end)

0
Worked! Thanks! SillyDamien 11 — 4y
Ad

Answer this question