ObjectValue From Client not replicating to the server script

So i have a client script that has a objectvalue inside of it.
So if a player points at a npc, its fires a server where the npc’s humanoid gets changed its health to TakeDamage(22), somehow if i try ‘‘if hum then end’’ its working but no errors meaning that the objectvalue from the client is empty?

is it true or not?
or must i learn something new?

Can you show me your code, what’s the location of the ObjectValue?

in a GUI client script.
The client basically does something like… aim at a npc with humanoid? set the npc model to objectvalue replicate to storage.

player.GUI.ObjectValue.Humanoid.Health = player.GUI.ObjectValue.Humanoid.Health - 33

thats how it works. also the script you want, well. here:

humanoid is Model of the NPC

local player = game.Players.LocalPlayer
mouse = player:GetMouse()
local humanoid = script.HumanoidTarget
while wait(0.1) do
	if mouse.Target ~= nil then

		local model = mouse.Target.Parent
		script.Enabled = false
		script.HumanoidTarget.Value = nil
		if model:FindFirstChildOfClass("Humanoid") then
			script.Enabled = true
			print ("Pointing at a model with Humanoid")
			game.ReplicatedStorage.ShootInv:FireServer()
			print (model.Torso.Position)
			humanoid.Value = model
		end
	end
end



SERVER script:

game.ReplicatedStorage.ShootInv.OnServerEvent:Connect(function(player, humanoid)
	local ui = player.PlayerGui
	wait(0.001)
	local hum = ui.Squad.SniperCrewTarget.HumanoidTarget
	local target = (ui.Name)
		target.Humanoid.Health = target.Humanoid.Health - 55
	workspace["Sniper Shot "]:Play()
end)


What is this supposed to mean? The target variable is a string, not a instance.

i added workspace to it, but it still doesn’t work.

so like Workspace.(NPC Name).Humanoid

1 Like

its now saying target is not a valid member of workspace

Try printing the name, see if it exist on the server, not on the client.

its printing ‘‘PlayerGui’’ 30

You are using the PlayerGui’s name, what are you exactly trying to do here?

OHHHH im blind. let me try that one sec.

now its printing a error saying ‘‘Squad’’ is not a valid member.

ObjectValues don’t replicate from client to server, AKA changing it’s value from the client will not change it for the server, and will remain the same instead.

well, any alternatives you can help?

Just send the value through a RemoteEvent.

values made or changed by the client are NOT replicated to the server.

There are specific exceptions to this, but in general, objects that don’t have physics can’t be replicated from the client to the server (i.e., the client can’t change the color of an anchored part).

not really, everything to the client isn’t replicated to the server, except the character and UIs of course.

See “Exceptions” section

1 Like