Problem in my chat system

  1. What is the issue?

Hi,
as you can see the text is getting slower
and i don’t know how to fix that,

here is the script i made:

local me = game.Workspace.NPC.ThekyrieMVP
local player = game.Players.LocalPlayer
script.Parent.Visible = false


while wait() do
	local distance = (me.HumanoidRootPart.Position - player.Character.HumanoidRootPart.Position).Magnitude
	print(distance)
	if distance <= 10 then
		me.ClickDetector.MouseClick:Connect(function()
			script.Parent.Visible = true
			player.Character.Humanoid.WalkSpeed = 0
			player.Character.Humanoid.JumpPower = 0
			for i = 1, #text do
				print("chatting")
				script.Parent.Text = string.sub(text, 1, i)
				wait(0.05)
			end
			wait(1)
			script.Parent.Visible = false
			player.Character.Humanoid.WalkSpeed = 16
			player.Character.Humanoid.JumpPower = 50
			wait(1)
			script.Parent.Text = ""
		end)
	end
end

thx for reading

2 Likes

im not sure i understand what the wait() in the “while wait() do” does if you want the script to loop you might want it to be “while true do” then add the wait()

Idk if that will fix it but you may consider changing it :slight_smile:

1 Like

yeah ty i changed it but it didn’t fixed it

oh ok, i also saw that you don’t have a debounce so when the person clicks while the event is still going on it will fire again so I would try to add a debounce unless you’ve already tried that :confused:

1 Like

okay ty lemme try that (30 chars)

wow it actually worked thank you

1 Like

no problem dude :slight_smile: good luck on you game :smiley:

1 Like