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

Welds are not welding to Player. What is wrong with this script? [SOLVED]

My welds don't do anything when I create them in a script but when I change their properties in the explorer while playing the game, they work perfectly. What do I need to do in order to make this work because I am very confused. It outputs no errors and the script runs perfectly creating both welds and assigning their properties.

function TestService:Spawn(Player, Weapon)
	if Weapon ~= Items.IDArray[Weapon] then
		game.ReplicatedStorage.SuccessMessage:FireClient(Player, "? Successfully found "..Weapon.." with ID "..Items.IDArray[Weapon].ID)
		
		-- Welding
		local WeaponSaid = game.ReplicatedStorage[Weapon]
		local Fake = WeaponSaid:Clone()
		Fake.Parent = game.Workspace[Player.Name]
		local WeldC0 = Instance.new("Weld", Fake.Model.Handle)
		local WeldC1 = Instance.new("Weld", game.Workspace[Player.Name]["Right Arm"])
		WeldC0.Name = "FakeHandle" 
		WeldC1.Name = "PlayerHandle"
		
		wait(0.5)
		Fake:SetPrimaryPartCFrame(CFrame.new(game.Workspace[Player.Name]["Right Arm"].Position))
		WeldC0.Part0 = WeaponSaid.Model.Handle
		WeldC0.Part1 = game.Workspace[Player.Name]["Right Arm"]
		
		wait(0.5)
		Fake:SetPrimaryPartCFrame(CFrame.new(game.Workspace[Player.Name]["Right Arm"].Position))
		WeldC1.Part0 = WeaponSaid.Model.Handle
		WeldC1.Part1 = game.Workspace[Player.Name]["Right Arm"]
		
		Fake:SetPrimaryPartCFrame(CFrame.new(game.Workspace[Player.Name]["Right Arm"].Position))
	else
		game.ReplicatedStorage.ErrorMessage:FireClient(Player, "? Sorry, I couldn't find "..Weapon.." in my Array!")
	end
end

7 comments

0

Also tried debug info and it prints fine.

0

Try WeldConstraint instead of Weld

0

also here at line 16 you are setting Part0 to WeaponSaid.Model.Handle ( thats inside replicated storage tho try setting it for Fake.Model.Handle)

0

Alright, thanks. I'll try that.

0

Yep, that has fixed it thanks.

0

Okey you can make it answered down below so poeple know its fixed!

0

Also if you can give me Reputation i would appreciate it!

1 answer

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