Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I return something in quotation marks?

Asked by 3 years ago
Edited 3 years ago

Here is my script

local function GetClosestPlayer()
    local LowestDistance = math.huge
    local ClosestCharacter = nil
    local Characters = {}
    for i,v in pairs(game:GetService("Players"):GetPlayers()) do
        if v.Character ~= nil and v ~= game.Players.LocalPlayer then
            table.insert(Characters, v.Character)
        end
    end
    for i,v in pairs(Characters) do
        if v ~= nil then
            if v:FindFirstChild("HumanoidRootPart") then
                local InitialDis = (v.HumanoidRootPart.Position - game.Workspace.CurrentCamera.CFrame.p).magnitude
                local Ray = Ray.new(game.Workspace.CurrentCamera.CFrame.p, (mouse.Hit.p - game.Workspace.CurrentCamera.CFrame.p).unit * InitialDis)
                local Part,Position = game.Workspace:FindPartOnRay(Ray, game.Workspace)
                local FinalDifference = math.floor((Position - v.HumanoidRootPart.Position).magnitude)
                if FinalDifference < LowestDistance then
                    ClosestCharacter = v
                    LowestDistance = FinalDifference
                end
            end
        end
    end
    local ClosestPlayer = game.Players:GetPlayerFromCharacter(ClosestCharacter)
    if ClosestPlayer ~= nil then
        return ClosestPlayer.name
    end

I want to return ClosestPlayer.name as a string so that I can print their name. Please help!

1 answer

Log in to vote
0
Answered by
Xyternal 247 Moderation Voter
3 years ago
message = "he said \"bye\" and left"
print (message

Please tell me if this answer works. If it does, don't forget to upvote it :P

0
Huh? I think you misunderstood my question. PhoneyMRS 5 — 3y
0
What did you want your question to be? Xyternal 247 — 3y
0
I was wondering how to return something in quotation marks so that I can print it, is it possible? PhoneyMRS 5 — 3y
0
k Xyternal 247 — 3y
Ad

Answer this question