You can write your topic however you want, but you need to answer these questions:
What do you want to achieve?
I want only private server owner have the free cam feature
What is the issue?
My code isn’t working
What solutions have you tried so far?
already search on yt and other social medias but none results
local LocalPlayer = game.Players.LocalPlayer
local PlayerGui = LocalPlayer:WaitForChild("PlayerGui")
local freeCamGui = PlayerGui:WaitForChild("Freecam")
if not LocalPlayer.UserId == game.PrivateServerOwnerId then
if PlayerGui then
if freeCamGui then
freeCamGui:Destroy()
end
end
end
I don’t know this count as a error or not but i just gonna send
PrivateServerOwnerId cannot be checked on the client, please check on the server.
local RemoteEvent = game.ReplicatedStorage:WaitForChild("RemoteEvent")
game.Players.PlayerAdded:Connect(function(player)
if not player.UserId == game.PrivateServerOwnerId then
RemoteEvent:FireClient(player)
end
end)
Server Script:
local Players = game:GetService("Players")
local RemoteEvent = game.ReplicatedStorage:WaitForChild("RemoteEvent")
RemoteEvent.OnServerEvent:Connect(function(player)
local playerGui = player:WaitForChild("PlayerGui")
local Freecam = playerGui:WaitForChild("Freecam")
if playerGui then
if Freecam then
Freecam:Destroy()
end
end
end)
EDIT: already tested it but still doesnt work, and no errors appears on the output
You need to run the script in ServerScriptService, a.k.a on the server. You can use remote events/functions. in short, Remote events send info from client-server or server-client.
– script
game.ReplicatedStorage.RemoteFunction.OnServerInvoke = function(player)
– check things here
return player.UserId == game.PrivateServerOwnerId
end
– local script
local isOwner = game.ReplicatedStorage.RemoteFunction:InvokeServer()