So I am creating a script thing and it uses local scripts. I have the issue that I don’t want any exploiters to be able to view the local script stuff so I used a remote function to try to add some security in. I have never used them before and getting a erorr so I am not sure how I could fix it.
Server Script:
local RS = game:GetService("ReplicatedStorage")
RS.EpicOne.OnServerEvent:Connect(function()
local player = game:GetService("Players")
--Links to the "Removes all of the first part"
local BackDrop = player.LocalPlayer.PlayerGui["Start UI"].BackDrop
local Image = player.LocalPlayer.PlayerGui["Start UI"].LighthouseLogo
local TextButton = player.LocalPlayer.PlayerGui["Start UI"].ClickThingFirst
local TextForButton = player.LocalPlayer.PlayerGui["Start UI"].ClickThingFirstBack
local TraieeQuizText = player.LocalPlayer.PlayerGui["Start UI"].TraineeQuiz
local WhoCreated = player.LocalPlayer.PlayerGui["Start UI"].CreatedByLifeDigger
--Links to the "Adds in the second part
-- Removes all of the first part
BackDrop.Visible = false
Image.Visible = false
TextButton.Visible = false
TextForButton.Visible = false
TraieeQuizText.Visible = false
WhoCreated.Visible = false
-- Adds in the second part
end)
Local Script:
local RS = game:GetService("ReplicatedStorage")
script.Parent.MouseButton1Click:Connect(function()
RS.EpicOne:FireServer()
end)
Like what Atom said, you can’t use LocalPlayer in a serverscript. A remote event to the server passes the player variable automatically, so you can use that instead. See this article for more information.
ALWAYS assume that the client is compromised. Manipulating the UI from the server side on a regular basis is generally frowned upon because it takes up processing power and isn’t particularly effective in stopping cheaters. There is usually a better solution to check for suspicious behavior.
Wait I don’t understand. Is that not what I did??? (I understand it’s not the best to do from the server side but it’s not a massive bit in it and only for one person).
When you’re receiving the event, you reference the player’s playerGui, not the local playerGui.
So this line: player.LocalPlayer.PlayerGui would become player.PlayerGui
Also, when you’re calling fireserver, I’m pretty sure the player is always passed, so I don’t believe you need that player argument on the client.
Finally, It’s best to handle gui inputs and etc on the client, instead of accessing the PlayerGui. This is due to client/server boundary not replicating for some input functions, e.g textbutton. While, I understand you’re trying to reduce the chances of exploiting, you shouldn’t use the server entirely for your game. There are some things such as Gui input, etc that should be handled on the client. Just have the appropriate sanity checks.
I fixed your code this should work let me know if it doesent
Server Script:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Remote = ReplicatedStorage.EpicOne
Remote.OnServerEvent:Connect(function(Player)
local PlayerGui = Player:WaitForChild("PlayerGui")
local StarterUI = PlayerGui:WaitForChild("Start UI")
local BackDrop = StarterUI:WaitForChild("BackDrop")
local Image = StarterUI:WaitForChild("LighthouseLogo")
local TextButton = StarterUI:WaitForChild("ClickThingFirst")
local TextForButton = StarterUI:WaitForChild("ClickThingFirstBack")
local TraieeQuizText = StarterUI:WaitForChild("TraineeQuiz")
local WhoCreated = StarterUI:WaitForChild("CreatedByLifeDigger")
BackDrop.Visible = false
Image.Visible = false
TextButton.Visible = false
TextForButton.Visible = false
TraieeQuizText.Visible = false
WhoCreated.Visible = false
end)
Local Script:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Remote = ReplicatedStorage.EpicOne
local Button = script.Parent
Button.MouseButton1Click:Connect(function()
Remote:FireServer()
end)
if you put the “player” paramiter in the event fire thing itll get the player when the remote is fired