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

Dosent weld part to the front of the player?

Asked by 4 years ago
Edited 4 years ago

I have a script where it welds a certain part to the front of the player. But it isnt working. Can someone help me?

local module = {}
function module.gui(plr)
    local player = game.Players:WaitForChild(plr)
    script.Part.Position = CFrame.new(player.Character.Head.Position + Vector3.new(0, 10, 0))
    local weld = Instance.new("WeldConstraint", script.Part)
    weld.Part0 = script.Part
    weld.Part1 = player.Character.Head
end
return module

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

first, you need to check if player is added. then, check if the character is added and you need to clone the part to make it works to every player This is the module:

return function(player)
    local char = player.Character
    local Clone = script.Part:Clone()
    Clone.Parent = char.Head
    Clone.Position = char.Head.Position + Vector3.new(0, 10, 0)
    local weld = Instance.new("WeldConstraint", Clone)
    weld.Part0 = Clone
    weld.Part1 = char.Head
end

this is the script to check:

game.Players.PlayerAdded:Connect(function(Player)
    Player.CharacterAdded:Connect(function(char) --Check The Character is loaded
        require(script.ModuleScript)(Player)
    end)
end)

try that and the part is above your player head, if this work please mark as an answer!:)

Ad

Answer this question