Help Making Leading Arrows For a Tycoon

I Don’t Know if this is supposed to be here.
So Recently my Tycoon Players are Getting Confused where to go.
And I want to know how I can do this:
image


Thanks!

10 Likes

They probably use beams from the player’s Character’s HumanoidRootPart to any open tycoons. They also possibly check if they’re open by putting a BoolValue inside each door, setting it true if it gets taken and false if it gets untaken.

Yea, Thats what I thought but like are there any tutorials how to do that?

The Roblox Developer Hub has a pretty good tutorial on beams if you want to read on it. Beam | Documentation - Roblox Creator Hub

I don’t think there’s any tutorials on this, however I can give you a kickstart:

local players = game:GetService("Players")
local doors = 1 --Set this to a Folder of the doors

players.PlayerAdded:Connect(function(plr)
    plr.CharacterAppearanceLoaded:Connect(function(character)
        for _, door in pairs(doors:GetChildren()) do
            if not door.BoolValue.Value then
               --Make a beam between the door and the character HRP here
           end
        end
   end)
end)
4 Likes

An easy solution to this would be to use beams. As you said you wanted a tutorial I will make you one quickly:


We will first need to create a LocalScript and put it anywhere on the client, I would put it in StarterPlayerScripts. The reason why we are running this on the client is because there is no need to get the server involved and waste the servers resources on a visual thing for the player. Also running it purely on the client it will make it so only you will be able to see the arrows and not everyone else assuming you have filtering enabled on.

You will also need to set up your tycoon doors for the beams to go to. You need to insert an Attachment into each door like so:
TycoonArrow

Now then, lets get onto coding this thing. First lets create a couple of our variables and put them in the LocalScript we just created:

local Players = game:GetService("Players") -- Gets player service
local Character = Players.LocalPlayer.CharacterAdded:wait() -- Waits for the character to load

Next we need to create a table to store all of the TycoonDoors in for easy access later on.

local tycoonDoors = {
	game.Workspace.TycoonBlue,
	game.Workspace.TycoonRed,
	game.Workspace.TycoonGreen,
}

Now we need to create our functions. We will have a CreateArrows function, a disableArrows function and a enableArrows function. Here is them set up:

local function createArrows()

end

local function disableArrows()

end

local function enableArrows()

end

We will first fill our createArrows function up. This function is responsible for setting up the beams and connecting them to the attachments. The way this function works is by looping through the doorsTable we created earlier and creates an beam for each door inside it. Here is the function filled up:

local function createArrows()
	for i,v in pairs(tycoonDoors) do -- Loops through the tycoonDoors table
		local beam = Instance.new("Beam") -- Creates the beam
		beam.Parent = v
		beam.Color = ColorSequence.new(Color3.fromRGB(0,0,0))
		
		local attachmentPlayer = Instance.new("Attachment")  -- Creates the player attachment
		attachmentPlayer.Name = "TycoonArrow"
		attachmentPlayer.Parent = Character:WaitForChild("HumanoidRootPart")
		
		beam.Attachment0 = v.Attachment -- Hooks the beam up to the door
		beam.Attachment1 = attachmentPlayer -- Hooks the beam up to the player
	end
end

createArrows() -- Runs the function

Now we will need to setup our disableArrows function up. This function is responsible for disabling the beams. Call this function whenever you want your arrows to be disabled. Here is the code:

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

Lastly we will setup our enableArrows function. This function responsible for enabling the arrows. Call this function whenever you want your arrows to be enabled again. Here is the code:

local function enableArrows()
	for i,v in pairs(tycoonDoors) do
		v.Beam.Enabled = true
	end	
end

Here is the full code:

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

local tycoonDoors = {
	game.Workspace.TycoonBlue,
	game.Workspace.TycoonRed,
	game.Workspace.TycoonGreen,
}

local function createArrows()
	for i,v in pairs(tycoonDoors) do
		local beam = Instance.new("Beam")
		beam.Parent = v
		beam.Color = ColorSequence.new(Color3.fromRGB(0,0,0))
		
		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
		v.Beam.Enabled = false
	end
end

local function enableArrows()
	for i,v in pairs(tycoonDoors) do
		v.Beam.Enabled = true
	end	
end
24 Likes

When i disable the beam it disables it for everyone. any fix for that?

1 Like