here i have created a script that is supposed to weld a model to the player humanoid root part
local rStorage = game:GetService("ReplicatedStorage") local morphItem = rStorage:WaitForChild("Morph") local maxMorphDistance = 5 morphItem.OnServerEvent:Connect(function(player, item) local distanceFromItem = player:DistanceFromCharacter(item.Morpher.Position) if distanceFromItem <= maxMorphDistance then -- morphcode here local copy = item:Clone() copy.Parent = item.Parent copy:SetPrimaryPartCFrame(CFrame.new(0, 50, 0)) local part = item.Morpher local Weld = Instance.new("Weld",part) print("done") -- problem starts below game:GetService("Players").PlayerAdded:Connect(function(player) player.CharacterAdded:Connect(function(character) print("a") local torso = game.Workspace:WaitForChild(player):WaitForChild("HumanoidRootPart") part.CFrame = torso.CFrame Weld.Part0 = part Weld.Part1 = torso print("DONE".. player) end) end) end end)
im having trouble getting the player, the only thing printed to console is "done". can anyone help?
local Players = game:GetService("Players") Players.PlayerAdded:Connect(function(player) player.CharacterAdded:Connect(function(char) --Script end) end)
im use all time this script
btw in in line 26 it only prints done because you didint do this :
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.