local rstorage = game:GetService("ReplicatedStorage") local event = rstorage:WaitForChild("OBJChanged") event.OnServerEvent:Connect(function() event.Objective.Value = script.Parent.OBJText.Text end)
OnServerEvent can only be used on the server Script 'Players.SunxLightz.PlayerGui.OBJGui.OBJ', Line 5
How do i fix this, i wanna make this show to every player
Objective gui when touches part fires event, if event fired in local script inside gui, the text changes
Well....... You are using .OnServerEvent in a local script, that's obvious.. You even answerd yourself, and the error shown is very easily comprehinsable. Always check your script carefully!
Now I guess you did this because in your server script youc ant refer to the LocalPlayer. Now isn't that just perfect! Your :FireServer function which is going to be inside your local script can also send to the server any given paramater. That's so helpful and the exact solution for your problem. Always use it.
Now let me explain what Is said
-This is your local script local player = game.Players.LocalPlayer -- this is the player, which can only be refered to locally local number = 72 -- this is a variable that were gonna use for testing local remote = game.ReplicatedStorage:WaitForChild("RemoteEvent") remote:FireServer(player, number) -- now you see i put our two variables in there as our 2 arguments, and were gonna send those into our server script, and like that we have access to the player, and also the number value
--Your server script local remote = game.ReplicatedStorage:WaitForChild("RemoteEvent") -- now remember that the server and client and that you want to make contact with eachother have to use the same rémote event! remote.OnServerEvent:Connect(function(player, number) print(player, number) -- it will print them succefully! Now see what I did? i put in the same arguments that i put in the local script! and now you got access to player and 72, i ho^pe you got the idea, and remember that this event will fire when :FireServer did its thing. end)
Im glad that i helped, and i hope you understood how remote events work. More Information!