Beam not appearing

local script in starter player scripts:


game.Players.LocalPlayer.CharacterAdded:Connect(function(character)
	local root = character:WaitForChild("HumanoidRootPart")
	local a0 = root:WaitForChild("RootRigAttachment")

	print("Character and root attachment found:", root.Name)

	task.wait(1)  -- Small delay to ensure everything is loaded

	module.castBeam(a0, character, game.Workspace:WaitForChild("test"))
	task.wait(3)
	module.castBeam(a0, character, game.Workspace:FindFirstChild("WORK"))
	task.wait(2)
	module.castBeam(a0, character, game.Workspace:FindFirstChild("Part2"))
end)

module script in replicated storage:


function module.castBeam(a0, char, target)
	print('executed')

	if char:FindFirstChildOfClass("Beam") then
		char:FindFirstChildOfClass("Beam"):Destroy()
	end

	local beam = script:WaitForChild("Beam"):Clone() -- Create a clone of our template
	local attachment = Instance.new("Attachment", target)
	local a1 = target:FindFirstChildOfClass("Attachment") -- Find the attachment in the part

	-- Debug: Check the distance between attachments
	if a0 and a1 then
		local distance = (a0.WorldPosition - a1.WorldPosition).Magnitude
		print("Distance between attachments: ", distance)
	end

	if a1 then -- If we found one, attach it
		beam.Attachment0 = a0 -- Set attachments
		beam.Attachment1 = a1

		-- Set beam properties for visibility
		beam.Width0 = 2
		beam.Width1 = 2
		beam.Color = ColorSequence.new(Color3.fromRGB(255, 0, 0))  -- Red color
		beam.Transparency = NumberSequence.new(0)  -- Fully opaque

		beam.Parent = char -- Or use workspace, depending on the setup
		print("Beam attached between:", a0.Parent.Name, "and", a1.Parent.Name)
	else -- If there isn't one, let the scripter know
		warn("No attachment was inserted into "..target:GetFullName())
	end
end

return module

as you see there are many comments on the script, that’s because i tried to use ai for debugging after it did not work regardless of anything I did, it still does not work, all the debug print commands print what they should be printing but the beam is invisible, the scripts run as intended, the attachments are made in the parts, the beam clone is parented to my character and its properties are all fine, as in the beam should be visible but regardless of anything i tried, its never visible

edit: I also just tried manually casting a beam between 2 set attachments and copied the beams properties from a YouTube video on beams so that the properties being set in such a way that would make the beam invisible would be impossible, wouldn’t you guess it the beam is still nowhere in sight despite copying exactly what the video showed. I don’t know what it could be at this point besides some studio bug.

2 Likes

I think there’s a bug right now because my beam stopped working in my game even though I changed nothing and it was working just fine.

2 Likes

i forgot to say that that script worked earlier and i also didn’t touch it, probably a bug as i don’t have any other explanation

This is exactly what is happening to me as well. It is probably a problem on Roblox’s end.

yeah same thing is happening to me, didn’t touch the beam at all. Has to be roblox-side

First of all, using Instance.new waits until it’s created successfully and returns the object created within the attachment variable. So the variable a1 is useless and clutter and could cause problems, since looking for an object is pricey performance wise.

As @mmii665 mentioned, this is currently a bug within’ studio. The only way to test this is if you load the game using the website to play-test.

I’m also having this same problem with it too. Everyone are having an issue with this just now.

1 Like