local uis = game:GetService("UserInputService")
local debounce = false
local name = "Dave"
local message = "Hey man, what's up?"
local dist = 7
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local playerGui = player:WaitForChild("PlayerGui")
local interact = game.ReplicatedStorage.Interact
while true do
for i, npc in pairs(workspace.NPCs:GetChildren()) do
if (char:WaitForChild("HumanoidRootPart").CFrame.p - npc.HumanoidRootPart.CFrame.p).magnitude <= dist then
interact.Parent = playerGui
uis.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.E and not debounce and interact.Parent == playerGui then
debounce = true
game.ReplicatedStorage.Remotes.StartDialog:FireServer(name, message, dist)
wait(1)
debounce = false
end
end)
else
interact.Parent = game.ReplicatedStorage
end
end
wait(1)
end
I'm trying to make a magnitude script so that when you're near an npc, it would show a gui. The problem is that it doesn't show the gui.

2 comments
Changes on the client do not replicate to the server, so whatever you do on the client in terms of setting a parent will not save to the server.
thanks man!