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 3 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.

local flashlight = script.Parent.light

local player = game.Players.LocalPlayer
local character = game.Workspace:FindFirstChild(player.Name)
    local weld = Instance.new("Weld",flashlight)
weld.Part0 = flashlight    
weld.Part1 = character["Torso"]
weld.C0 = CFrame.new(0, 0, 0) + Vector3.new(0,character["RightHand"].Size.Y/2,0)

1 answer

Log in to vote
1
Answered by 3 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:

--Making Part
local Part = Instance.new("Part")
Part.Name = "Part"

Part.Parent = workspace

Solution:

game.Players.PlayerAdded:Connect(function(Player)
    Player.CharacterAdded:Connect(function(Character)
        if not Character.Humanoid:FindFirstChild("Flashlight") then
            local Flashlight = Instance.new("SpotLight")
            Flashlight.Name = "Flashlight"

            --Config
            Flashlight.Angle = 90
            Flashlight.Brightness = 20
            Flashlight.Range = 16
            --End

            Flashlight.Parent = Character.HumanoidRootPart
        end
    end)
end)

Hope It Helps!

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

Answer this question