Problem with fired event not doing anything

I am trying to make it so that when an event is fired, it will change the value of a NumberValue parented by a ScreenGui. It prints that it fires in the first script, but it doesn’t print anything in the second script for some reason, and doesn’t change any value. What am I doing wrong? (I took this DevForum post’s script and tried to modify it to fit my needs. )

Script 1

Details

Type: LocalScript
Parent: TextLabel
TextLabel Name: ItemID
TextLabel Parent: Frame
Frame Parent: ScreenGui
ScreenGui Parent: StarterGui

 local box = script.Parent
 local event  = game.ReplicatedStorage.ItemIDNum

 box.FocusLost:Connect(function()--when the user stops inputting text
     local text = box.Text 
     event:FireServer(text)--we get the number and send that value to the Server
     print("event was fired")
 end)   

Script 2

Details

Type: LocalScript
Parent: RemoteEvent
RemoteEvent Name: ItemIDNum
RemoteEvent Parent: ReplicatedStorage

local Event = game.ReplicatedStorage.ItemIDNum
local gui = game.Players.LocalPlayer.PlayerGui.InfoProvider
Event.OnServerEvent:Connect(function(Player, amt)
	if type(amt) == "number" then
       gui.ItemIDNumber.Value = amt	
        print("Player Put An Item ID in the Item ID Box")
    end
end)

Thanks for reading!

localscripts don’t run outside of ReplicatedFirst, StarterCharacterScripts, StarterPlayerScripts, and the PlayerGui (StarterGui). Move the localscript to one of those locations and it should work.
If the second script isn’t a localscript like your details says (I would hope it’s not a localscript, as you can’t use OnServerEvent on the client, and remoteEvents aren’t for localscript to localscript communication, use a bindableEvent for that.), move it into the workspace or serverscript service and it will run, scripts don’t run in storage containers, so it can’t pick up the event being fired.

1 Like

I hadn’t known until now, thanks!
The reason I used a localscript is bacause a localscript has a localplayer, allowing me to get to the playergui through that.

Value still doesn’t change?
I put the text of the second script inside of a regular script, then put that script in ServerScriptService, and still nothing.

Are there any errors in the output?

The issue here is that you cannot access a “LocalPlayer” from the server script. If you want to directly change the GUI from the server, then I’d recommend sending in the GUI as one of the parameters in the local script. Meaning where you fire server with text, include GUI after the text parameter and then on the server you should be able to access the GUI from there and change it.

Change this to

local gui = game.Players.LocalPlayer:WaitForChild("PlayerGui").InfoProvider