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

Im trying to make my own dialog system but the screengui only shows up when i reset?


text = "Hiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii"

script.Parent.Touched:connect(function(hit)
	if hit.Parent:FindFirstChild('Humanoid') then 
		frame = Instance.new("Frame")
		frame.Parent = game.StarterGui.ScreenGui
		frame.Position = UDim2.new(0, 25, 0, 25)
		frame.Size = UDim2.new(0, 100, 0, 50)
		TL = Instance.new("TextLabel")
		TL.Parent = frame
		TL.Position = UDim2.new(0, 25, 0, 25)
		TL.Size = UDim2.new(0, 100, 0, 50)
		Speech = TL
		for i = 1, #text do
			Speech.Text = text:sub(1, i)
			wait(.02)
			script:remove()
		end
	end
end

Well what happens is the player hits a part with this script in it and nothing happens but if you go to explorer and look inside of starter gui there is already a frame with and textlabel in it but it doesnt show but until i reset (Note that there is already a screengui in starter gui before the game runs) What supposed to happen is pretty much everything i just said except the part where it doesnt show up until i reset (NOTE: the gui also isnt supposed to be neat)

1 answer

✓ Accepted answer

Lets start of with telling the difference between StarterGui and PlayerGui. StarterGui is all the guis that will show up when you join the game and reset and stuff. PlayerGui is the gui in the player, which is what the player sees. Assuming your game is not FE so I can do less work, here is what you should do.

text = "Hiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii"

script.Parent.Touched:Connect(function(hit) --:connect was deprecated, use :Connect()
    if hit.Parent:FindFirstChild('Humanoid') then 
        frame = Instance.new("Frame")
        frame.Parent = game:GetService('Players'):GetPlayerFromCharacter(hit.Parent).PlayerGui
        frame.Position = UDim2.new(0, 25, 0, 25)
        frame.Size = UDim2.new(0, 100, 0, 50)
        TL = Instance.new("TextLabel")
        TL.Parent = frame
        TL.Position = UDim2.new(0, 25, 0, 25)
        TL.Size = UDim2.new(0, 100, 0, 50)
        Speech = TL
        for i = 1, #text do
            Speech.Text = text:sub(1, i)
            wait(.02)
            script:Destroy() --:remove was deprecated for a long time.
        end
    end
end

Please try to keep up with deprecated items and what you should do instead.

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