This is a local script, inside a Dummy. What I am trying to achieve is if a player is near the Dummy, the Dummy will chat the following.
local plr = game:GetService("Players").LocalPlayer
local char = plr:WaitForChild("Character") or plr.CharacterAdded:Wait()
local Dummy = script.Parent.HumanoidRootPart
local closestDistance = 10
local chat = game:GetService("Chat")
while true do
task.wait(1)
local distance = (char.HumanoidRootPart.Position - Dummy.Position).magnitude
if distance <= closestDistance then
chat:Chat(Dummy.Head,"Welcome to Sabway!")
end
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
local plr = game:GetService("Players").LocalPlayer
local char = script.Parent
local Dummy = game.Workspace:WaitForChild("R15")
local closestDistance = 10
local chat = game:GetService("Chat")
while wait(1) do
local distance = (char.HumanoidRootPart.Position - Dummy.PrimaryPart.Position).magnitude
if distance <= closestDistance then
chat:Chat(Dummy.Head,"Welcome to Sabway!")
end
end