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

Welding a model to a player?

Asked by 6 years ago
Edited 6 years ago

This is a script that I have:

local player = game.Players.LocalPlayer
local character = player.CharacterAdded:wait() or workspace[player.Name]


spawn(function() 
    local part = character["Torso"]
    local weld = workspace.Sword.Sheath.WeldMain
    weld.Part0 = workspace.Sword.Sheath 
    weld.Part1 = character["Torso"]
    weld.C0 = CFrame.new(0, -1, 0)
    weld.C0 = CFrame.fromOrientation(-1.5, 0, -1)
end)

So basically, what I want is for a model to be welded onto a player's back the second the player joins.

The problem is, whenever I try it out on a server, it doesn't weld it onto the player's back.

I need help identifying the problem.

1 answer

Log in to vote
0
Answered by 6 years ago

Im pretty sure this is being done in a local script and if the game is FE, it should be done on a server script. Heres is how you do this: -- in a server script

local Players = game:GetService("Players")
function CharacterAdded(character) -- it also gives you a variable for the character
    -- this gets called when the player is added so you do all the stuff you did in the local script except now it runs on the server
    local part = character["Torso"]     
    local weld = workspace.Sword.Sheath.WeldMain       
    weld.Part0 = workspace.Sword.Sheath     
    weld.Part1 = character["Torso"]     
    weld.C0 = CFrame.new(0, -1, 0)      
    weld.C0 = CFrame.fromOrientation(-1.5, 0, -1)

end
Players.PlayerAdded:connect(function(plyr) plyr.CharacterAdded:connect(CharacterAdded) end)
0
Thanks for your answer! GIassWindows 141 — 6y
Ad

Answer this question