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
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.