Beam Tutorial problem

I’m trying to make a tutorial for a player when it’s joining that he sees some beam lines that tell him where to go to claim a tycoon. The script i currently have it’s working but only if there is no tycoon claimed. If there was a player that claimed the tycoon and another one joins, he does not see the lines. Anyone who can help with that please? I’m also trying to make only one beam shown, not all 4 but idk how to do that either.

This is the script:

local Players = game:GetService("Players")
local Character = Players.LocalPlayer.CharacterAdded:wait()

local tycoonDoors = {
	game.Workspace["Zednov's Tycoon Kit"].Tycoons.Amber.Entrance["Touch to claim!"].Head,
	game.Workspace["Zednov's Tycoon Kit"].Tycoons.Amethyst.Entrance["Touch to claim!"].Head,
	game.Workspace["Zednov's Tycoon Kit"].Tycoons.Ruby.Entrance["Touch to claim!"].Head,
	game.Workspace["Zednov's Tycoon Kit"].Tycoons.Sapphire.Entrance["Touch to claim!"].Head,
}




local function createArrows()
	for i,v in pairs(tycoonDoors) do
		local beam = Instance.new("Beam")
		beam.Parent = v
		beam.Color = ColorSequence.new(Color3.fromRGB(255, 85, 0))
		beam.Texture = "rbxassetid://7791559535"
		beam.TextureMode = "Static"
		beam.FaceCamera = true
		beam.Transparency = NumberSequence.new{
			NumberSequenceKeypoint.new(0.0,0.8),
			NumberSequenceKeypoint.new(1.0,0.8),
		}
		beam.LightEmission = 1 -- use additive blending
		beam.LightInfluence = 0 -- beam not influenced by light
		beam.TextureLength = 1 -- repeating texture is 1 stud long 
		beam.TextureSpeed = -1 -- slow texture spee
		local attachmentPlayer = Instance.new("Attachment")
		attachmentPlayer.Name = "TycoonArrow"
		attachmentPlayer.Parent = Character:WaitForChild("HumanoidRootPart")

		beam.Attachment0 = v.Attachment
		beam.Attachment1 = attachmentPlayer
	end
end

createArrows()

local function disableArrows()
	for i,v in pairs(tycoonDoors) do -- Loops through the doors table
		v.Beam.Enabled = false -- Makes the beam not enabled
	end
end

local function enableArrows()
	for i,v in pairs(tycoonDoors) do -- Loops through the doors table
		v.Beam.Enabled = true -- Makes the beam not enabled
	end	
end

local function CheckIfBeam()

		

	if Players.LocalPlayer.Team.Name == "For Hire" then
		enableArrows()
	else
		disableArrows()
		end

end


wait(1)


while wait(1) do
	CheckIfBeam()
end

And it looks like this if you are the first player:

1 Like

Assuming you have the max player amount of your game set to the number of tycoons per game, there should always be one extra tycoon for your player when they join.

You are looping through every tycoon door and setting the beams for it, when you only need one beam. The first thing you need to do is set up a returning function that iterates through every tycoon door. Check if the tycoon is claimed, and if it is not claimed, return that value.

The reason why no beams appear is because in your CheckIfBeam function, if the player is not on the “For Hire” team, it disables all beams, making it appear that there are no beams.

Taking my advice, you should restructure your code like this:

-- loop through all tycoon doors
-- if door is not claimed then,
-- enable beam for ONLY the door that is not claimed
``
2 Likes

I’ve tried modifying in CheckIfBeam function but I’ve broke it more. Could you point me in a direction on where should I start and what should I modify please? Thank you.

Edit: And yes, there are 4 tycoons, with 4 player max

2 Likes

Actually, I need a direction too lol