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

Why does this RemoteFunction not work? (More in Desc)

Asked by 4 years ago

I'm trying to utilize a remote function to InvokeClient from the server-side and then after, completing a function on the server script. (Clicking a button) Return / send back data from a text box to the server to display to the rest of the players what a player said. I can't figure out for the life of me why it's not working!

Server Script

local result = enableRoastBox:InvokeClient(Player1) 

local function loopedRound(res)
    print(Player1.Name .. " Said: " .. res)
    print("WORKED!")
end

print("Result = " .. result)
loopedRound(result)

Client Script

workspace:WaitForChild(game.Players.LocalPlayer.Name)

replicatedStore = game:WaitForChild("ReplicatedStorage")
events = replicatedStore:FindFirstChild("Events")

enableRoastGUI = events:WaitForChild("enableRoastGUI")

player = game.Players.LocalPlayer

local gameSettings = workspace:FindFirstChild("GameSettings")

local p1 = gameSettings.p1Name
local p2 = gameSettings.p2Name
local roast = gameSettings.Roast

text = script.Parent
frame = script.Parent.Parent
done = script.Parent.Parent.Done

function enableRoast()
    if player.Name == p1.Value or p2.Value then
    print("START")

    frame.Visible = true
    frame:TweenSizeAndPosition(UDim2.new(0.665, 0, 0.094, 0), UDim2.new(0.167, 0, 0.891, 0), "Out", "Quad", 1, true)
    text:TweenSizeAndPosition(UDim2.new(1, 0, 0.61, 0), UDim2.new(0, 0, 0.177, 0), "Out", "Quad", 1, true)

    done.MouseButton1Down:Connect(function()
        print("DONE CLICKED")
        frame:TweenSizeAndPosition(UDim2.new(0, 0, 0.094, 0), UDim2.new(0.167, 0, 0.891, 0), "Out", "Quad", 1, true)
        text:TweenSizeAndPosition(UDim2.new(0, 0, 0.61, 0), UDim2.new(0, 0, 0.177, 0), "Out", "Quad", 1, true)
        wait(1)
        frame.Visible = false

        --print("Invoking Server")
        --print("Invoked Server")

        roast.Value = text.Text
        return roast.Value

    end)

    --return text.Text

    else
        print("Failed to show roastBox")
    end

end

enableRoastGUI.OnClientInvoke = enableRoast
0
What does player1 in the server script equal? Its possible that moo1210 587 — 4y

1 answer

Log in to vote
0
Answered by
moo1210 587 Moderation Voter
4 years ago
Edited 4 years ago

At line 39 where you run return roast.Value, your returning it to done.MouseButton1Down:Connect(function() not function enableRoast(), try putting it under line 47. It also appears that you are not declaring player1, if you are could you please edit your post to show what player1 equals? It's possible that it isn't working because player1 isn't declared, or you just aren't showing us it, but in order to help you anymore I will need to know that.

0
It returned succesfully. But I've had that happen before, the problems it it doesnt return what the player typed in the textBox SwiftyDeveloper 4 — 4y
0
Player1 is declared as a player object that was randomly selected from the game. SwiftyDeveloper 4 — 4y
0
could you print text.Text and tell me what it says then? moo1210 587 — 4y
0
It's all good I fixed it! SwiftyDeveloper 4 — 4y
Ad

Answer this question