So basically, I am making it if the player is near the dummy, the dummy would chat the following dialog. But it doesn’t work.
There is an error, Workspace.Dummy.Script:5: attempt to index nil with 'DistanceFromCharacter'
local player = game.Players.LocalPlayer
local MAX_RANGE = 15
local chat = game:GetService("Chat")
while player:DistanceFromCharacter(workspace.Dummy.Head.Position) < MAX_RANGE do
chat:Chat(script.Parent.Head,"Welcome to Sabway!")
end
local chat = game:GetService("Chat")
local players = game:GetService("Players")
local player = players.LocalPlayer
local dummy = workspace:WaitForChild("Dummy")
local hrp = dummy:WaitForChild("HumanoidRootPart")
local head = dummy:WaitForChild("Head")
while true do
task.wait(1)
local distance = player:DistanceFromCharacter(hrp.Position)
if distance <= 10 then
chat:Chat(head, "Hello world!")
end
end