Welding and cloning part not working

This script does not work:


local players = game:GetService('Players')
local rep = game:GetService("ReplicatedStorage")

function Triggered(Plr)
	local Beam = rep.Connector:Clone()
	local weld = Instance.new("Weld")
	local BallSocket = Instance.new("BallSocketConstraint")
	weld.Part0 = Beam
	weld.Part1 = Plr.Character.Head

end

players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(char)
		local promptClone = script.RequestPrompt:Clone()
		promptClone.Parent = char:FindFirstChild("NameTag")
		promptClone.ActionText = "Link up with ".. player.Name
		
		promptClone.Triggered:Connect(Triggered)
		
	end)
end)

And I have no idea why.

3 Likes

Maybe try using weld constraints instead of welds?

1 Like

what doesn’t work what’s the problem

1 Like

When I activate the proximity prompt, nothing happens, nothing spawns in, and there are no errors.

When your Triggered function runs, nothing gets parented. Try Parenting your welds and constraints to something.

1 Like

shouldn’t you try setting the position of Beam oh yea and parent as @SnazpantsMixer said

Default parent of stuff is nil so… yea, parenting

I have parented weld to the beam, still nothing.

Okay but the beam as well was not parented, so now you’ll need to parent the beam to something in the workspace. Cloning something leaves it in this nil space until you place it into the location you desire

That spawns it in so good, but now it is at some random place at the map, and I cant seem to position it on the player.

So now it spawns in the player, kinda good, but it well always clone a in a different way depending on which way the player is looking, how do I make it so that no matter where the player is looking, it spawns at the same rotation.

Can you provide your code?

Essentially you need to reference the position of an attachment (when talking about the beams or constraints) to the player’s humanoidRootPart’s CFrame LookVector. With that it’d go forward from the player’s character. Note the look Vector is just a unit, so you’ll need to multiply it by however far you want the position to go

Dont worry about, fixed it and forget to tell you, sorry. But you were a big part in the process, thank you for your time!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.