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

How do I weld a tool to the player's torso?

Asked by 4 years ago

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.

1local flashlight = script.Parent.light
2 
3local player = game.Players.LocalPlayer
4local character = game.Workspace:FindFirstChild(player.Name)
5    local weld = Instance.new("Weld",flashlight)
6weld.Part0 = flashlight   
7weld.Part1 = character["Torso"]
8weld.C0 = CFrame.new(0, 0, 0) + Vector3.new(0,character["RightHand"].Size.Y/2,0)

1 answer

Log in to vote
1
Answered by 4 years ago

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
2local Part = Instance.new("Part")
3Part.Name = "Part"
4 
5Part.Parent = workspace

Solution:

01game.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)
16end)

Hope It Helps!

0
Good solution, upvoted! Xapelize 2658 — 4y
0
@Xapelize Thanks! The_Saver31 260 — 4y
0
thanks so much!! Lolbit_exe 24 — 4y
0
@Lolbit_exe Np! The_Saver31 260 — 4y
Ad

Answer this question