so basically, i'm trying to make a script where it sends text to a gui local script and has a server message pop up for everyone in the server, but its giving me the error of "Unable to cast value to Object", heres my code
gui script:
local messageWaitSigns = {"?", ".", "!", ";", ":"} local messageWaitDelay = 0.5 local commaWaitDelay = 0.25 local textInterval = 0.01 local debounce = true local camera = Instance.new("Camera", script.Parent) function Message(text) for i = 1, #text do script.Parent.Text.Text = string.sub(text, 1, i) if string.sub(text, i, i) == "," then wait(commaWaitDelay) end for _, v in pairs(messageWaitSigns) do if string.sub(text, i, i) == v then wait(messageWaitDelay) end end wait(textInterval) end end game:GetService("ReplicatedStorage").Dialogue.OnClientEvent:Connect(function(text) Message(text) end)
firing event script:
game.ReplicatedStorage.Dialogue:FireClient("testing testing 123")
I think the solution would just be to put a tostring() function and change #text to string.len(text)
local messageWaitSigns = {"?", ".", "!", ";", ":"} local messageWaitDelay = 0.5 local commaWaitDelay = 0.25 local textInterval = 0.01 local debounce = true local camera = Instance.new("Camera", script.Parent) function Message(text) for i = 1, string.len(text) do script.Parent.Text.Text = string.sub(text, 1, i) if string.sub(text, i, i) == "," then wait(commaWaitDelay) end for _, v in pairs(messageWaitSigns) do if string.sub(text, i, i) == v then wait(messageWaitDelay) end end wait(textInterval) end end game:GetService("ReplicatedStorage").Dialogue.OnClientEvent:Connect(function(text) Message(tostring(text)) end)