I'm trying to weld part0 to the characters head but i can't seem to get the character
function onClicked() local Character = Player.Character or Player.CharacterAdded:Wait() local w = Instance.new("Weld") w.Parent = script.Parent w.Part1 = script.Parent w.Part0 = Player.Head end script.Parent.ClickDetector.MouseClick:connect(onClicked)
ClickDetector event has a PlayerWhoClicked paramater.
So, by adding "Player" into the parameter section of the function, this should work:
function onClicked(Player) local Character = Player.Character or Player.CharacterAdded:Wait() local w = Instance.new("Weld") w.Parent = script.Parent w.Part1 = script.Parent w.Part0 = Player.Head end script.Parent.ClickDetector.MouseClick:Connect(onClicked)