LocalScript
local UIS = game:GetService("UserInputService")
local NPC = workspace:WaitForChild("NPC")
local event = game.ReplicatedStorage.Substract
local CurrentNPC = game.ReplicatedStorage.CurrentNPC
local player = game:GetService("Players").LocalPlayer
local char = player.Character or player.CharacterAdded:wait()
local maxDistance = 10
UIS.InputBegan:Connect(function(input)
if input.UserInputType == Enum.UserInputType.Keyboard then
if input.KeyCode == Enum.KeyCode.E then
if UIS:GetFocusedTextBox() == nil then
for i, v in pairs(NPC:GetChildren()) do
local mag = (v.HumanoidRootPart.Position - char.HumanoidRootPart.Position).magnitude
if mag <= 10 then
CurrentNPC.Value = v.Name
event:FireServer()
end
end
end
end
end
end)
Server Script
local event = game.ReplicatedStorage.Substract
local NPC = workspace.NPC
local currentNPC = game.ReplicatedStorage.CurrentNPC
event.OnServerEvent:connect(function(player)
local stats = player:WaitForChild("leaderstats")
local present = stats:WaitForChild("Presents")
if present ~= nil then
if present.Value >= 1 then
present.Value = present.Value - 1
print(currentNPC.Value)
end
end
end)
When I print(currentNPC.Value) which is in the ServerScript, it just prints blank. But when I checked the value for the CurrentNPC in the ReplicatedStorage it is the name of the NPC for example "Test". When I print the currentNPC in the LocalScript it does show the name of the NPC.

2 comments
What is the expected output supposed to be?
Supposed to print "Test" which is the name of the npc. Actually I want to compare if the name of the CurrentNPC is the same with v.Name(in LocalScript)