Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Make a Player-Part Beam ?

Asked by
mist0s 38
5 years ago
Edited 5 years ago

Hi, I want to make a Player-Part Beam, its for indicate the way. But it doesn't work. Here is the code:

01local Players = game:GetService("Players")
02 
03Players.PlayerAdded:Connect(function(player)
04 
05local start = Instance.new("Attachment")
06start.Name = "start"
07start.Parent = player.character:FindFirstChild("LowerTorso")
08 
09 
10local Beam = Instance.new("Beam")
11Beam.Name = "Beam"
12Beam.Parent = workspace
13Beam.Texture = "rbxassetid://136011733"
14Beam.TextureLength = 6
15Beam.TextureMode = "Wrap"
View all 23 lines...

Thanks for answer :D

1 answer

Log in to vote
0
Answered by
noammao 294 Moderation Voter
5 years ago
Edited 5 years ago
01local Players = game:GetService("Players")
02 
03Players.PlayerAdded:Connect(function(player)
04player.CharacterAdded:Connect(function(Character)
05local start = Instance.new("Attachment")
06start.Name = "start"
07start.Parent = Character:WaitForChild("HumanoidRootPart")
08 
09 
10local Beam = Instance.new("Beam")
11Beam.Name = "Beam"
12Beam.Parent = workspace
13Beam.Texture = "rbxassetid://136011733"
14Beam.TextureLength = 6
15Beam.TextureMode = "Wrap"
View all 24 lines...

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.

01local Players = game:GetService("Players")
02local player = Players.LocalPlayer
03local Character = player.Character or player.CharacterAdded:Wait()
04local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")
05 
06local start = Instance.new("Attachment")
07start.Name = "start"
08start.Parent = HumanoidRootPart
09 
10 
11local Beam = Instance.new("Beam")
12Beam.Name = "Beam"
13Beam.Parent = workspace
14Beam.Texture = "rbxassetid://136011733"
15Beam.TextureLength = 6
View all 23 lines...

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:

01local Players = game:GetService("Players")
02local player = Players.LocalPlayer
03local Character = player.Character or player.CharacterAdded:Wait()
04local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")
05 
06local Active = game.Workspace.PartActive
07local invs = game.Workspace.PartInvs
08 
09local start = Instance.new("Attachment")
10start.Name = "start"
11start.Parent = HumanoidRootPart
12 
13 
14local Beam = Instance.new("Beam")
15Beam.Name = "Beam"
View all 42 lines...

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.

0
Dude, it work, really THANKS ! mist0s 38 — 5y
0
No problem dude : )  Also, I hate to ask but can you upvote me please? I really need it to get to the next rank. Thankies! noammao 294 — 5y
0
Sorry I can't upvote because I don't have 25 reputation. I also have a question: how to make for the beam to being see by one player ? mist0s 38 — 5y
0
Put the code in a local script. Then only that player will be able to see it. I can post in my answer. noammao 294 — 5y
View all comments (4 more)
0
You know a lot of things !! Thanks !! And one last question (sorry but it very difficult for me), how to make a part when the player touch the part, the beam became invisible and vice versa ? mist0s 38 — 5y
0
Sorry, Could you explain in more detail? I'll help of course. noammao 294 — 5y
0
Yes, so I want to make, when a player touch a part, his beam became invisible and when he touch another part his beam became visible mist0s 38 — 5y
0
Done. I'll edit it. noammao 294 — 5y
Ad

Answer this question