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

How do I prevent breaking welds on death?

Each time a player resets or dies they loose their sword. I need this to stop because this is a fighting game and loosing your sword after dying would be really sad.

local Swprd = game.ServerStorage.BackSword
local repStorage = game.ReplicatedStorage

game.Players.PlayerAdded:Connect(function(plr)
	local SS = Swprd:Clone()
	local weldPart = SS.WeldPart
	local char = plr.Character or plr.CharacterAdded:Wait()
	local HMR = char.Torso
	SS.Parent = char
	local weld = Instance.new("Weld", char)
	weld.Name = "Welder"
	weld.Part0 = HMR
	weld.Part1 = weldPart
	weld.Parent = weldPart
end)

That is the server script for when they enter

local player = game.Players.LocalPlayer
local repStorage = game.ReplicatedStorage
local playerChar = player.Character or player.CharacterAdded:Wait()

local function activate()
	if not playerChar:FindFirstChild("BackSword") then
		playerChar.HandSword:Destroy()
		repStorage.SworBd:FireServer()
	elseif playerChar:FindFirstChild("BackSword") then
		playerChar.BackSword:Destroy()
		repStorage.Sword:FireServer()
	end
end

game:GetService("UserInputService").InputBegan:Connect(function(input, isTyping)
	if isTyping then return end
	if input.KeyCode == Enum.KeyCode.One then
		activate()
	end
end)

That is the local script (there are two remotes one that does the same thing as the first script I showed and another remote that gives the player the HandSword)

6 comments

0

Try putting it in startergear your tools

0

They are models not tools

0

Oh

0

I suggest asking these types of questions on the dev forums...

0

Maybe just add the tool every time u respawn?

0

so basically you want the sword to weld to the character each time they respawn?

1 answer

✓ Accepted answer

From what I understand, you're trying to get the sword to weld again after the character respawns.

First ServerScript:

local Swprd = game:GetService('ServerStorage').BackSword
local repStorage = game:GetService('ReplicatedStorage')

game:GetService('Players').PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(char)
		repeat wait() until char and char:FindFirstChild('Torso')
		local SS = Swprd:Clone()
		local weldPart = SS.WeldPart
		local HMR = char.Torso
		SS.Parent = char
		local weld = Instance.new("Weld")
		weld.Name = "Welder"
		weld.Part0 = HMR
		weld.Part1 = weldPart
		weld.Parent = weldPart
	end)
end)

1 comment

1

Thank you

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