Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Table to store the lines
- local lines = {}
- -- Function to create or update lines from your character to other players
- local function updateLinesToPlayers()
- local player = game.Players.LocalPlayer -- Get the local player
- while true do
- for _, otherPlayer in pairs(game.Players:GetPlayers()) do
- if otherPlayer ~= player then
- if player.Character and otherPlayer.Character then
- local playerCharacter = player.Character
- local otherCharacter = otherPlayer.Character
- local playerRoot = playerCharacter:FindFirstChild("HumanoidRootPart")
- local otherRoot = otherCharacter:FindFirstChild("HumanoidRootPart")
- if playerRoot and otherRoot then
- local lineKey = player.UserId .. "-" .. otherPlayer.UserId -- Unique key for each line
- local distance = (otherRoot.Position - playerRoot.Position).Magnitude
- if lines[lineKey] then
- lines[lineKey].Size = Vector3.new(0.1, 0.1, distance)
- lines[lineKey].CFrame = CFrame.new(playerRoot.Position, otherRoot.Position) * CFrame.new(0, 0, -distance / 2)
- else
- local line = Instance.new("Part")
- line.Anchored = true
- line.CanCollide = false
- line.BrickColor = BrickColor.new("Bright red") -- Adjust the color as needed
- line.Size = Vector3.new(0.1, 0.1, distance)
- line.CFrame = CFrame.new(playerRoot.Position, otherRoot.Position) * CFrame.new(0, 0, -distance / 2)
- line.Parent = workspace
- lines[lineKey] = line
- end
- elseif lines[lineKey] then
- -- Destroy the line if either player's character is missing
- lines[lineKey]:Destroy()
- lines[lineKey] = nil
- end
- end
- end
- end
- wait() -- Update every 1 second (adjust as needed for performance)
- end
- end
- -- Start the line updating loop in a separate thread
- spawn(updateLinesToPlayers)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement