How do I prevent breaking welds on death?
Asked by
5 years ago Edited 5 years ago
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.
01 | local Swprd = game.ServerStorage.BackSword |
02 | local repStorage = game.ReplicatedStorage |
04 | game.Players.PlayerAdded:Connect( function (plr) |
05 | local SS = Swprd:Clone() |
06 | local weldPart = SS.WeldPart |
07 | local char = plr.Character or plr.CharacterAdded:Wait() |
08 | local HMR = char.Torso |
10 | local weld = Instance.new( "Weld" , char) |
14 | weld.Parent = weldPart |
That is the server script for when they enter
01 | local player = game.Players.LocalPlayer |
02 | local repStorage = game.ReplicatedStorage |
03 | local playerChar = player.Character or player.CharacterAdded:Wait() |
05 | local function activate() |
06 | if not playerChar:FindFirstChild( "BackSword" ) then |
07 | playerChar.HandSword:Destroy() |
08 | repStorage.SworBd:FireServer() |
09 | elseif playerChar:FindFirstChild( "BackSword" ) then |
10 | playerChar.BackSword:Destroy() |
11 | repStorage.Sword:FireServer() |
15 | game:GetService( "UserInputService" ).InputBegan:Connect( function (input, isTyping) |
16 | if isTyping then return end |
17 | if input.KeyCode = = Enum.KeyCode.One then |
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)