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?
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)
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.
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).