#Server can see the beam but player can't

1 messages · Page 1 of 1 (latest)

odd glen
#

Screenshots

rotund trench
#

Show your code

#

Assuming thats a Beam instance connected between two attachments, my first guess is the attachment thats far from the player is out of streaming range

odd glen
#

local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local player = Players.LocalPlayer

local function setupCharacter(character)

local hrp = character:WaitForChild("HumanoidRootPart")
repeat
    task.wait(0.2)
until workspace:FindFirstChild("Trees")

local treeFolder = workspace:WaitForChild("Trees")
repeat
    task.wait(0.2)
until #treeFolder:GetChildren() > 0
local a0 = Instance.new("Attachment")
a0.Name = "RootPartAttach"
a0.Parent = hrp

local beam = Instance.new("Beam")
beam.Name = "Beam"
beam.Attachment0 = a0
beam.Width0 = 0.15
beam.Width1 = 0.15
beam.Color = ColorSequence.new(Color3.fromRGB(0, 255, 0))
beam.Transparency = NumberSequence.new(0.2)
beam.LightEmission = 1
beam.FaceCamera = true
beam.Enabled = false
beam.Parent = hrp

local Rock

local function findNearestRock()
    local nearestRock
    local minDistance = math.huge

    for _, tree in pairs(treeFolder:GetChildren()) do
        local rock = tree:FindFirstChild("Rock")
        if rock and rock:IsA("BasePart") then
            local distance = (hrp.Position - rock.Position).Magnitude
            if distance < minDistance then
                minDistance = distance
                nearestRock = rock
            end
        end
    end

    return nearestRock
end

local function updateBeam()
    if not Rock or not Rock.Parent then
        Rock = findNearestRock()
    end

    if Rock then
        if not beam.Attachment1 or beam.Attachment1.Parent ~= Rock then
            if beam.Attachment1 then
                beam.Attachment1:Destroy()
#

end

            local a1 = Instance.new("Attachment")
            a1.Name = "TreeAttachment"
            a1.Parent = Rock
            beam.Attachment1 = a1

        end

        beam.Enabled = true
    else
        beam.Enabled = false
    end
end

RunService.Heartbeat:Connect(function()
    updateBeam()
end)

treeFolder.ChildAdded:Connect(function(child)
    task.wait(0.2)
    updateBeam()
end)

treeFolder.ChildRemoved:Connect(function(child)
    if Rock and not Rock.Parent then
        Rock = nil
        updateBeam()
    end
end)

end

if player.Character then
setupCharacter(player.Character)
end
player.CharacterAdded:Connect(setupCharacter)

odd glen
rotund trench
odd glen
#

I made server script just to check if the beam works correctly and then remade it to the local

rotund trench
#

Oh so those two screenshots weren't taken at the same time?

odd glen
#

They were

#

They were made on the server script

#

If I run it from a local script, then neither the server nor the player will see it, but everything will be fine in Explorer

#

I fixed it lol

#

u couldn't see it bc the parent of beam for HumanoidRootPrat