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

my remote event is not working correctly and is giving me an error i don't understand?

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")

1 answer

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)

1 comment

0

still didn't work :/

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