here i have created a script that is supposed to weld a model to the player humanoid root part
01 | local rStorage = game:GetService( "ReplicatedStorage" ) |
02 | local morphItem = rStorage:WaitForChild( "Morph" ) |
03 |
04 | local maxMorphDistance = 5 |
05 | morphItem.OnServerEvent:Connect( function (player, item) |
06 | local distanceFromItem = player:DistanceFromCharacter(item.Morpher.Position) |
07 | if distanceFromItem < = maxMorphDistance then |
08 | -- morphcode here |
09 | local copy = item:Clone() |
10 | copy.Parent = item.Parent |
11 | copy:SetPrimaryPartCFrame(CFrame.new( 0 , 50 , 0 )) |
12 |
13 | local part = item.Morpher |
14 | local Weld = Instance.new( "Weld" ,part) |
15 | print ( "done" ) |
im having trouble getting the player, the only thing printed to console is "done". can anyone help?
1 | local Players = game:GetService( "Players" ) |
2 |
3 | Players.PlayerAdded:Connect( function (player) |
4 | player.CharacterAdded:Connect( function (char) |
5 |
6 | --Script |
7 |
8 | end ) |
9 | end ) |
im use all time this script
btw in in line 26 it only prints done because you didint do this :
1 | print ( "DONE" ..player.Name) |
I think your problem could be because you're using PlayerAdded, that only runs when a player joins and you're firing the event BEFORE that player added even has a chance to run when it's supposed to, I'd suggest doing a for i,v inpairs(game:GetService("Players")) loop then just searching for the player through that.