Dialogue typewrite effect it's not working with function (please help)

Here is the actual game file if this helps more:
Horror Game.rbxl (230.5 KB)

1 Like

You named it TextLabel, not Label

1 Like

Still is not working, So the 3 server scripts that are in the frame was the entire dialogue, but I’ve watched a video on YouTube that told me it’s better to make a local script inside the text label and I’ve wrote the code from the tutorial in the local script. I don’t care if the script is local or server but I just want this fixed because I have no clue what to do. I can give you Team Create if that helps more or I can send pictures and videos. Thank you.

1 Like

Look, just move the script’s code to the LocalScript in your ScreenGui1.

1 Like

Can you please write me the code exactly how it’s supposed to be because I tried placing it everywhere and it’s still not working. I’m dumb

1 Like

Something like this just get the TextLabel throught the PlayerGui

--// Variables
local cam = workspace.CurrentCamera
local camPart = workspace["MenuCamera"]
local mouse = game:GetService("Players").LocalPlayer:GetMouse()
local PlayBTN = script.Parent.BG.PlayButton
local scary = game.Workspace.scaryplay

--// Set cam
repeat
	wait()
	cam.CameraType = Enum.CameraType.Scriptable
until
cam.CameraType == Enum.CameraType.Scriptable

local function typewrite(object,text,length)
	for i = 1,#text,1 do
		object.Text = string.sub(text,1,i)
		task.wait(#text / length)
	end
end

--// Move cam
local maxTilt = 10
game:GetService("RunService").RenderStepped:Connect(function()
	cam.CFrame = camPart.CFrame * CFrame.Angles(
		math.rad((((mouse.Y - mouse.ViewSizeY / 2) / mouse.ViewSizeY)) * -maxTilt),
		math.rad((((mouse.X - mouse.ViewSizeX / 2) / mouse.ViewSizeX)) * -maxTilt),
		0
	)
end)


function Play()
	cam.CameraType = Enum.CameraType.Custom
	script.Parent:Destroy()
	scary:Play()
	local lp = game:GetService("Players").LocalPlayer
	local playbtn = lp.PlayerGui:WaitForChild("ScreenGui1"):WaitForChild("BG"):WaitForChild("PlayButton")
		typewrite("TextLabelHere", 'subscribe bro', 0.05)
end

PlayBTN.MouseButton1Click:Connect(Play)
2 Likes

I get this error: Infinite yield possible on 'Players.wcristy.PlayerGui:WaitForChild(“ScreenGui1”)

1 Like

so i checked the code and i think i found your problem
this code in the screen gui with the play button destroys the play button

function Play()
	cam.CameraType = Enum.CameraType.Custom
	script.Parent:Destroy()
	scary:Play()
end

and then in the other local script you are attempting to change the text on the play button while its destroyed

playbtn.MouseButton1Click:Connect(function()
	typewrite(playbtn, 'subscribe bro', 0.05)
end)

if you’re trying to make it so that the text on the textlabel that the script is in you would change it to this

playbtn.MouseButton1Click:Connect(function()
	typewrite(script.Parent, 'subscribe bro', 0.05)
end)
3 Likes

OMG IS WORKING!
Thank you so so so much!

1 Like

It’s working perfectly fine but I still got this error: Infinite yield possible on 'Players.wcristy.PlayerGui:WaitForChild(“ScreenGui1”)

1 Like

thats because the LocalScript in ScreenGui1 destroys ScreenGui1 when the play button is pressed

1 Like

Edit: I solved the error, thank you!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.