#script issue with 2 parts

11 messages · Page 1 of 1 (latest)

golden holly
#

(please note that i have zero to no knowledge of coding and i have copied other code to make this)

#

pistol: ```local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local debounce = false

local Pistol = ReplicatedStorage:WaitForChild("Pistol") -- put the name of the sword here
local Part = script.Parent

Part.Touched:Connect(function(hit) -- 'hit' is what touched the Part

if hit.Parent:FindFirstChildWhichIsA("Humanoid") then -- if humanoid exists

    local player = Players:GetPlayerFromCharacter(hit.Parent)

    if player then
        if player.Backpack:FindFirstChild("Pistol") or player.Character:FindFirstChild("Pistol") then -- if sword exists in the backpack or is already equipped

            player.Character:WaitForChild("Humanoid"):UnequipTools() -- unequips any tool
            player.Backpack:FindFirstChild("Pistol"):Destroy()-- removes the sword

        else -- if sword is not in the backpack or if the sword isnt equipped

            Pistol:Clone().Parent = player.Backpack-- clones and places the sword in the backpack
        end
    end
end

end)```

#

ak: ```local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local debounce = false

local ak = ReplicatedStorage:WaitForChild("ak") -- put the name of the sword here
local Part = script.Parent

Part.Touched:Connect(function(hit) -- 'hit' is what touched the Part

if hit.Parent:FindFirstChildWhichIsA("Humanoid") then -- if humanoid exists

    local player = Players:GetPlayerFromCharacter(hit.Parent)

    if player then
        if player.Backpack:FindFirstChild("ak") or player.Character:FindFirstChild("ak") then -- if sword exists in the backpack or is already equipped

            player.Character:WaitForChild("Humanoid"):UnequipTools() -- unequips any tool
            player.Backpack:FindFirstChild("ak"):Destroy()-- removes the sword

        else -- if sword is not in the backpack or if the sword isnt equipped

            ak:Clone().Parent = player.Backpack-- clones and places the sword in the backpack
        end
    end
end

end)```

modest ice
#

is it just me or isnt that video moving? just a image

modest ice
golden holly
compact quiverBOT
#

studio** You are now Level 1! **studio

modest ice
golden holly
golden holly
#

im gonna close this