Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How do I prevent breaking welds on death?

Asked by
Shubu13 29
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.

01local Swprd = game.ServerStorage.BackSword
02local repStorage = game.ReplicatedStorage
03 
04game.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
09    SS.Parent = char
10    local weld = Instance.new("Weld", char)
11    weld.Name = "Welder"
12    weld.Part0 = HMR
13    weld.Part1 = weldPart
14    weld.Parent = weldPart
15end)

That is the server script for when they enter

01local player = game.Players.LocalPlayer
02local repStorage = game.ReplicatedStorage
03local playerChar = player.Character or player.CharacterAdded:Wait()
04 
05local 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()
12    end
13end
14 
15game:GetService("UserInputService").InputBegan:Connect(function(input, isTyping)
16    if isTyping then return end
17    if input.KeyCode == Enum.KeyCode.One then
18        activate()
19    end
20end)

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)

0
Try putting it in startergear your tools JesseSong 3916 — 5y
0
They are models not tools Shubu13 29 — 5y
0
Oh JesseSong 3916 — 5y
0
I suggest asking these types of questions on the dev forums... JesseSong 3916 — 5y
View all comments (2 more)
0
Maybe just add the tool every time u respawn? IcyMizu 122 — 5y
0
so basically you want the sword to weld to the character each time they respawn? Mayk728 855 — 5y

1 answer

Log in to vote
1
Answered by
Mayk728 855 Moderation Voter
5 years ago
Edited 5 years ago

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

First ServerScript:

01local Swprd = game:GetService('ServerStorage').BackSword
02local repStorage = game:GetService('ReplicatedStorage')
03 
04game:GetService('Players').PlayerAdded:Connect(function(plr)
05    plr.CharacterAdded:Connect(function(char)
06        repeat wait() until char and char:FindFirstChild('Torso')
07        local SS = Swprd:Clone()
08        local weldPart = SS.WeldPart
09        local HMR = char.Torso
10        SS.Parent = char
11        local weld = Instance.new("Weld")
12        weld.Name = "Welder"
13        weld.Part0 = HMR
14        weld.Part1 = weldPart
15        weld.Parent = weldPart
16    end)
17end)
1
Thank you Shubu13 29 — 5y
Ad

Answer this question