Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Welding a model to a player?

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

✓ Accepted answer

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)

1 comment

0

Thanks for your answer!

This discussion is preserved as it was. New answers, comments, and votes are closed.