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

Why isn't Player:DistanceFromCharacter working?

Asked by
oxifrl 0
3 years ago
Edited 3 years ago
local player = game.Players.LocalPlayer
local runService = game:GetService("RunService")
local guiPart = workspace.MultiplayerComingSoon

local nearPart = false

runService.RenderStepped:Connect(function()
    if player:DistanceFromCharacter(guiPart.Position) < 2 then
        nearPart = true
        workspace.MultiplayerComingSoon.BillboardGui.TextLabel.Visible = true
    else
        nearPart = false
        workspace.MultiplayerComingSoon.BillboardGui.TextLabel.Visible = false
    end
end)

I started scripting a couple weeks ago, I've been kind of off and on and haven't really focused on learning much since I started. Anyways, I'm trying to make it to where a text label pops up saying "Multiplayer is coming soon" when the player is near a part used for multiplayer. I've read up on it a little bit and I've seen all this magnitude stuff, not sure how to go about it. Any suggestions on making this work?

1 answer

Log in to vote
0
Answered by
gunter5 17
3 years ago

dont even need DistanceFromCharacter just do this.

local player = game.Players.LocalPlayer
local runService = game:GetService("RunService")
local guiPart = workspace.MultiplayerComingSoon

local nearPart = false

runService.RenderStepped:Connect(function()
    if (player.Character:WaitForChild("HumanoidRootPart").Position - guiPart.Position).Magnitude < 2 then
        nearPart = true
        workspace.MultiplayerComingSoon.BillboardGui.TextLabel.Visible = true
    else
        nearPart = false
        workspace.MultiplayerComingSoon.BillboardGui.TextLabel.Visible = false
    end
end)
0
Magnitude is just as effective and more versatile as it can be used for any physical instance :] gunter5 17 — 3y
Ad

Answer this question