I can't implement the code related to checking the local player

I want the bool value to be created in order to check whether the player is local or not, but the fact is that the value is always true, I roughly understand why it is always true

Server Code:

local RP = game:GetService("ReplicatedStorage")
local Remotes = RP:WaitForChild("Remotes")
local Remote = Remotes.CHECKLPLR
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")

function Checking(Bool, LocalPlayer)
	if LocalPlayer then
		Bool.Value = true
	else
		Bool.Value = false
	end
end

Remote.OnServerEvent:Connect(function(LocalPlayer)
	local Bool = Instance.new("BoolValue")
	Bool.Name = "CheckLocal"
	Bool.Value = false
	Bool.Parent = LocalPlayer.Character
	
	RunService.Heartbeat:Connect(function()
		Checking(Bool, LocalPlayer)
	end)

	
end)

Local code:

local RP = game:GetService("ReplicatedStorage")
local Remotes = RP:WaitForChild("Remotes")
local Remote = Remotes.CHECKLPLR
local Players = game:GetService("Players")
local LocalPlayer = Players.LocalPlayer

LocalPlayer.CharacterAdded:Connect(function()
	Remote:FireServer(LocalPlayer)
end)



game.Players.LocalPlayer is simply a reference to the client’s player. All players are essentially serverside.

just curious, what are you trying to do here?

I want to create a bool value in order to use it for a hitbox, whether it’s a local player or not

well i will say that in your script the value will always be true because you are taking the player argument and sending it to the checking function which just checks if localPlayer exists. which it always will, so you’re never going to get to that else part of the checking function.

To understand this, whenever a remote event is fired to the server, the very first parameter is always going to be the player that sent it. You don’t need the local player to send that as a parameter.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.