Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

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

Asked by
Stea_my 48
3 years ago

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

Log in to vote
0
Answered by 3 years ago

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)

0
still didn't work :/ Stea_my 48 — 3y
Ad

Answer this question