How to get the player in a GUI without using local scripts

hi, can someone tell me to get the player in a GUI without using local scripts
because hackers/cheaters can sometimes see or modify local scripts

You can always give/modify a UI for a player, through the server

I currently have a local and normal script for buying an item in my shop, is it possible to do this in 2 normal scripts?

--script
task.wait(2)
script.Parent.RemoteEvent.OnServerEvent:Connect(function(player)
	if player.leaderstats.burger.Value <= 2 then
	if	player.leaderstats.Yums.Value -  125 < 0 then 
		return
	else
		player.leaderstats.Yums.Value -= 125
		end
	end
end)

script.Parent.RemoteEvent2.OnServerEvent:Connect(function(player)
	if player.leaderstats.burger.Value <= 2 then
	player.leaderstats.burger.Value = 2
	end
end)

script.Parent.RemoteEvent3.OnServerEvent:Connect(function(player)
	if player.leaderstats.burger.Value <= 2 then
	for _, tool in ipairs(player.Backpack:GetChildren()) do
		if tool:IsA("Tool") then
			tool:Destroy()
		end
end
	if player.Character:FindFirstChildOfClass("Tool") then
		player.Character:FindFirstChildOfClass("Tool"):Destroy()
end 
	local backpack = player:WaitForChild("Backpack")
	local eynew = game.ReplicatedStorage.Tools:WaitForChild("burger2")
	print(player.Name)
	task.wait(0.1)
	eynew:Clone().Parent = backpack
		print("cloned new tool")
		end
 end)


--local script
task.wait(2)
local player = game.Players.LocalPlayer
local Yums = player:WaitForChild("leaderstats").Yums
local Burger = player:WaitForChild("leaderstats").burger


script.Parent.MouseButton1Click:Connect(function(player)
	if Burger.Value >= 2 then 
		script.Parent.Text = "already owned"
		task.wait(1)
		script.Parent.Text = "cost: 125 Yums"		
	elseif Yums.Value >= 125 and Burger.Value <= 2 then
		script.Parent.RemoteEvent:FireServer()
		script.Parent.RemoteEvent2:FireServer()
		script.Parent.RemoteEvent3:FireServer()
	else
		script.Parent.Text = "Not enough Yums"
		task.wait(1)
		script.Parent.Text = "cost: 125 Yums"
	end
	
end)

I don’t really know what you’re trying to achieve but if you’re trying to make a gui show for certain players then do this:

  • Put a script in ServerScriptService
  • Parent the GUI to the script,
  • In the script, make it so that every time a player joins, check if they have a specific username. Whenever they do, clone the GUI and put it in game.Players.[PlayerName].PlayerGUI

Not possible. A GUI will probably be sitting somewhere in PlayerGUI e.g
Scripts only work if they meet the requirements:
image

This is inevitable, have all your important decisions done on the Server and handling userinput and such on the client

maybe it will work if I clone the gui’s into the player’s playergui and search for the parent “player” into the script

could you please explain what you’re trying to achieve

I’m protecting my item buy scripts in a shop for hackers/cheaters and it’s in a gui

Sorry, but I’m pretty sure scripts only work in certain areas like @wf_sh said