Local Script:
(When a button is pressed, a Screen Gui I have will close btw, and I added the RemoteEvent to do something in the Server once Gui closes.)
local opened = script.Parent.Parent local close = script.Parent local ReplicatedStorage = game:GetService("ReplicatedStorage") local remoteEvent = ReplicatedStorage:WaitForChild("RE1") close.MouseButton1Up:Connect(function() opened:TweenPosition( UDim2.new(0.32, 0,-0.771, 0), "Out", "Quad", 1, false ) local theTextYouWantToMove = game.StarterGui.AgendaGUI.AgendaFrame.AgendaTxt remoteEvent:FireServer(theTextYouWantToMove.Text) end)
Script in (ServerScriptService):
(When someone types in something in a textbox, i want whatever they typed to be the new text in a part in workspace)
local ReplicatedStorage = game:GetService("ReplicatedStorage") local remoteEvent = ReplicatedStorage:WaitForChild("RE1") local function ChangeText(player, text) local NAText = workspace.Agenda.Agenda.SurfaceGui.NA NAText.Text = text end remoteEvent.OnServerEvent:Connect(ChangeText)
Btw I used the RemoteEvent scripts from the Roblox Dev Website and followed the steps but for some reason what I am doing is not working. Please help!
um for the top script there is no input parameter, it just fires the server it doesnt have the text string, also when you did the connect function, you only have 1 parameter you also need to include the player parameter i think, so it should be
1.
local opened = script.Parent.Parent local close = script.Parent close.MouseButton1Up:Connect(function() opened:TweenPosition( UDim2.new(0.32, 0,-0.771, 0), "Out", "Quad", 1, false ) local ReplicatedStorage = game:GetService("ReplicatedStorage") local remoteEvent = ReplicatedStorage:WaitForChild("RE1") remoteEvent:FireServer(gui.Text) end)
2.
local ReplicatedStorage = game:GetService("ReplicatedStorage") local remoteEvent = ReplicatedStorage:WaitForChild("RE1") local function ChangeText(player, NAText) local NAText = game.Workspace.Agenda.Agenda.SurfaceGui.NA.Text NAText = game.StarterGui.AgendaGUI.AgendaFrame.AgendaTxt end remoteEvent.OnServerEvent:Connect(plr, ChangeText)
actually i might have misunderstood this, i see another problem that i think is what you meant, when you connected, you didnt connect to the function, you jsut wrote :CONNECT and then the parameters, theres no function there, so it should be something like this:
2.
local ReplicatedStorage = game:GetService("ReplicatedStorage") local remoteEvent = ReplicatedStorage:WaitForChild("RE1") local function ChangeText(player, NAText) local NAText = game.Workspace.Agenda.Agenda.SurfaceGui.NA.Text NAText = game.StarterGui.AgendaGUI.AgendaFrame.AgendaTxt end remoteEvent.OnServerEvent:Connect( ChangeText(player_, NAText_) )
although i dont like making a function and calling it in a different line, so i prefer this:
local ReplicatedStorage = game:GetService("ReplicatedStorage") local remoteEvent = ReplicatedStorage:WaitForChild("RE1") remoteEvent.OnServerEvent:Connect(function(player, NAText) local NAText = game.Workspace.Agenda.Agenda.SurfaceGui.NA.Text NAText = game.StarterGui.AgendaGUI.AgendaFrame.AgendaTxt end)
Okay! I moved the variables because its ugly to create a new local for every connection if not needed. The localplayer is automatically passed when firing to the server so its unnecessary to add it, just pass the text.
local opened = script.Parent.Parent local close = script.Parent local ReplicatedStorage = game:GetService("ReplicatedStorage") local remoteEvent = ReplicatedStorage:WaitForChild("RE1") close.MouseButton1Up:Connect(function() opened:TweenPosition( UDim2.new(0.32, 0,-0.771, 0), "Out", "Quad", 1, false ) local theTextYouWantToMove = reference.it.here -- never add an objects value at the end of a variable, add the object itself and then reference the value later remoteEvent:FireServer(theTextYouWantToMove.Text) --here we pass the text as 'object.value', Text in this instance end)
On here, we have the same issue with you trying to store an objects value in a variable, dont do! Also you attempted to pass 'NAText' as a parameter and then proceed to set its value, why pass it if you just want to change it?
local ReplicatedStorage = game:GetService("ReplicatedStorage") local remoteEvent = ReplicatedStorage:WaitForChild("RE1") local function ChangeText(player, thePassedText) local NAText = workspace.Agenda.Agenda.SurfaceGui.NA -- a little trick here, just use workspace.X not game.Workspace :) NAText.Text = thePassedText -- we set the workspace surface to the value passed through the event, easy! end remoteEvent.OnServerEvent:Connect(ChangeText)