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
4 years ago
Edited 4 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.

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)

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

1 answer

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

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
Thank you Shubu13 29 — 4y
Ad

Answer this question