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

Script not changing text of TextLabel?

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)

2 comments

0

Is it a localscript?

0

Yes

1 answer

✓ Accepted answer

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)

1 comment

0

Worked! Thanks!

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