How do I weld a tool to a player's torso, I'm trying to make a flashlight tool that doesnt get held in the hand, rather it's a light coming from the player's body like this (https://thief-simulator.fandom.com/wiki/Flashlight?file=Flashlight.jpg), here is my code, it just makes the light at the middle of the map.
1 | local flashlight = script.Parent.light |
2 |
3 | local player = game.Players.LocalPlayer |
4 | local character = game.Workspace:FindFirstChild(player.Name) |
5 | local weld = Instance.new( "Weld" ,flashlight) |
6 | weld.Part 0 = flashlight |
7 | weld.Part 1 = character [ "Torso" ] |
8 | weld.C 0 = CFrame.new( 0 , 0 , 0 ) + Vector 3. new( 0 ,character [ "RightHand" ] .Size.Y/ 2 , 0 ) |
Actually, You can just add a light to the player body.
Every single time character is Loaded, you can add Light to the player Torso by using Instance.new()
!
For Example:
1 | --Making Part |
2 | local Part = Instance.new( "Part" ) |
3 | Part.Name = "Part" |
4 |
5 | Part.Parent = workspace |
Solution:
01 | game.Players.PlayerAdded:Connect( function (Player) |
02 | Player.CharacterAdded:Connect( function (Character) |
03 | if not Character.Humanoid:FindFirstChild( "Flashlight" ) then |
04 | local Flashlight = Instance.new( "SpotLight" ) |
05 | Flashlight.Name = "Flashlight" |
06 |
07 | --Config |
08 | Flashlight.Angle = 90 |
09 | Flashlight.Brightness = 20 |
10 | Flashlight.Range = 16 |
11 | --End |
12 |
13 | Flashlight.Parent = Character.HumanoidRootPart |
14 | end |
15 | end ) |
16 | end ) |
Hope It Helps!