#InvokeServer returning a Player?

4 messages · Page 1 of 1 (latest)

olive nymph
#

I'm trying to give a value to the server from a localscript, then the server will find an object from the serverstorage whose name is the value, and return that object's value (StringValue) to the localscript, I can't explain well

LOCALSCRIPT

local rs = game:GetService("ReplicatedStorage")
local questionAdd = rs:WaitForChild("questionAdd")
local crntquestion = rs:WaitForChild("question")

local function typeWriter(text, textLabel)
    for i = 1, #text do
        textLabel.Text = string.sub(text, 1, i)
        wait(0.05)
    end
end
    local questionObject = questionAdd:InvokeServer(crntquestion.Value)
crntquestion:GetPropertyChangedSignal("Value"):Connect(function()
    questionObject = questionAdd:InvokeServer(crntquestion.Value)
    typeWriter(questionObject, textLabel)
end)```
Script
```local rs = game:GetService("ReplicatedStorage")
local questions = game:GetService("ServerStorage"):WaitForChild("questions")

rs.questionAdd.OnServerInvoke = function(question)
    local questionObject = questions:FindFirstChild(question)
    if questionObject then
        return questionObject.Value
    else
        warn("Question object does not exist!")
    end
end```
It's giving me the warning, also, when I type question in the script, it says it's a player object or something
dark tapir
#

the first parameter of the callback should be the Player

#

Remote Events and Functions when invoking the server transmit the Player

olive nymph
#

oh