Hello! I want to make an arrow (beam), that shows you the next button (or e.g. if there are 2 buttons, one is randomly chosen) in my Tycoon-System.
This is what I got so far (the script is in StarterCharacterScripts):
local plr = game.Players.LocalPlayer
local char = script.Parent
local partsToBeam = {}
local function pathToPart(beam, attachment0, part)
local attachment1 = part:FindFirstChildOfClass("Attachment")
if attachment1 then
beam.Attachment0 = attachment0
beam.Attachment1 = attachment1
else
warn("You forgot to add an attachment (--> "..part.Name..")")
end
end
plr.PlayerGui.MainGui.Bar.ShowArrow.TextButton.MouseButton1Click:Connect(function()
local humanoidRootPart = char:WaitForChild("HumanoidRootPart")
local attachment0 = humanoidRootPart:WaitForChild("RootRigAttachment")
if plr.PlayerGui.MainGui.Bar.ShowArrow.BackgroundColor3 == Color3.fromRGB(216, 216, 216) then
local beam = script:WaitForChild("Beam"):Clone()
pathToPart(beam, attachment0, workspace:WaitForChild("SpawnLocation"))
beam.Parent = char
plr.PlayerGui.MainGui.Bar.ShowArrow.BackgroundColor3 = Color3.fromRGB(0, 255, 0)
else
char.Beam:Destroy()
plr.PlayerGui.MainGui.Bar.ShowArrow.BackgroundColor3 = Color3.fromRGB(216, 216, 216)
end
end)
→ The post that I based myself on (original post): How is this "Follow the arrows" system made?
This is, how to get all buttons in the Tycoon:
for _, allTycoons in pairs(workspace.Tycoons:GetChildren()) do
if allTycoons.Values.PlayerName.Value == plr.Name and allTycoons.Values.Owned.Value == true then
for _, allButtons in pairs(allTycoons.Buttons:GetChildren()) do
end
end
end
Ty for any answers!