Hi, I want to make a Player-Part Beam, its for indicate the way. But it doesn't work. Here is the code:
local Players = game:GetService("Players") Players.PlayerAdded:Connect(function(player) local start = Instance.new("Attachment") start.Name = "start" start.Parent = player.character:FindFirstChild("LowerTorso") local Beam = Instance.new("Beam") Beam.Name = "Beam" Beam.Parent = workspace Beam.Texture = "rbxassetid://136011733" Beam.TextureLength = 6 Beam.TextureMode = "Wrap" Beam.TextureSpeed = 0.8 Beam.FaceCamera = true Beam.Attachment0 = start Beam.Attachment1 = game.Workspace.Part1.Attachment1 Beam.Color = "Really Red" Beam.Width0 = 3 Beam.Width1 = 3 end)
Thanks for answer :D
local Players = game:GetService("Players") Players.PlayerAdded:Connect(function(player) player.CharacterAdded:Connect(function(Character) local start = Instance.new("Attachment") start.Name = "start" start.Parent = Character:WaitForChild("HumanoidRootPart") local Beam = Instance.new("Beam") Beam.Name = "Beam" Beam.Parent = workspace Beam.Texture = "rbxassetid://136011733" Beam.TextureLength = 6 Beam.TextureMode = "Wrap" Beam.TextureSpeed = 0.8 Beam.FaceCamera = true Beam.Attachment0 = start Beam.Attachment1 = game.Workspace.Part1.Attachment1 Beam.Color = ColorSequence.new(Color3.fromRGB(0,255,0),Color3.fromRGB(255,0,0)) Beam.Width0 = 3 Beam.Width1 = 3 end) end)
Here you go. For some reason The "start" attchment didn't want to be a parent of the lower torso. So I had to change it to HumanoidRootPart. Also, Beam.Color uses a color sequence. So you can't use brick colors for it.
Edit: If you only want one person to see the beams you should use local scripts.
local Players = game:GetService("Players") local player = Players.LocalPlayer local Character = player.Character or player.CharacterAdded:Wait() local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart") local start = Instance.new("Attachment") start.Name = "start" start.Parent = HumanoidRootPart local Beam = Instance.new("Beam") Beam.Name = "Beam" Beam.Parent = workspace Beam.Texture = "rbxassetid://136011733" Beam.TextureLength = 6 Beam.TextureMode = "Wrap" Beam.TextureSpeed = 0.8 Beam.FaceCamera = true Beam.Attachment0 = start Beam.Attachment1 = game.Workspace.Part1.Attachment1 Beam.Color = ColorSequence.new(Color3.fromRGB(0,255,0),Color3.fromRGB(255,0,0)) Beam.Width0 = 3 Beam.Width1 = 3
Note that if you put the script inside game.StarterPlayer.StarterPlayerScripts
the beam will stop once you die. It will not reset. But if you put it inside of StarterGui it will. The reason is because StarterGui reloads its children everytime you spawn.
Edit 2:
local Players = game:GetService("Players") local player = Players.LocalPlayer local Character = player.Character or player.CharacterAdded:Wait() local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart") local Active = game.Workspace.PartActive local invs = game.Workspace.PartInvs local start = Instance.new("Attachment") start.Name = "start" start.Parent = HumanoidRootPart local Beam = Instance.new("Beam") Beam.Name = "Beam" Beam.Parent = workspace Beam.Texture = "rbxassetid://136011733" Beam.TextureLength = 6 Beam.TextureMode = "Wrap" Beam.TextureSpeed = 0.8 Beam.FaceCamera = true Beam.Attachment0 = start Beam.Attachment1 = game.Workspace.Part1.Attachment1 Beam.Color = ColorSequence.new(Color3.fromRGB(0,255,0),Color3.fromRGB(255,0,0)) Beam.Width0 = 3 Beam.Width1 = 3 Active.Touched:Connect(function(player) -- "player" is the part that touched the part. local Humanoid = player.Parent:FindFirstChild("Humanoid") -- Declaring that the object contains a part called Humanoid. if Humanoid then -- Check if it contains a humanoid. And if true, do. Beam.Enabled = true end end) invs.Touched:Connect(function(player) local Humanoid = player.Parent:FindFirstChild("Humanoid") if Humanoid then Beam.Enabled = false end end)
There are multiple ways to do this but this is the way I chose to approach the issue. This isn't ideal since it goes against the DRY-principle but it at least works. Also, I want to clarify that both "Active" and "Invs" are parts that I've put in the workspace. They are not the same part as Part1
. These are separate parts.
The reason I check if the part that touched contains a humanoid is because the touched event fires whenever anything touches it. So while it's on the ground the touched event will fire a lot of times without you even being near it.
Hope that clarifies it.