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

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

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

1 comment

0

What does player1 in the server script equal? Its possible that

1 answer

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.

4 comments

0

It returned succesfully. But I've had that happen before, the problems it it doesnt return what the player typed in the textBox

0

Player1 is declared as a player object that was randomly selected from the game.

0

could you print text.Text and tell me what it says then?

0

It's all good I fixed it!

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