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

"current parent is NULL, new parent is PLAYER NAME" how do i fix this??

Asked by 3 years ago
  1. what the code is supposed to do - equip and unequip sword
  2. what the code is actually doing - its equipping unequipping only one time but then it isnt working
  3. the code itself- local script that fires the event to say the server script make sword equip unequip

local UIS = game:GetService("UserInputService")

local Bool = game.ReplicatedStorage:WaitForChild("Equipped") Bool = false local equipped = false

UIS.InputBegan:Connect(function(input)

if input.KeyCode == Enum.KeyCode.E then


    if equipped == false then
    equipped = true
    game.ReplicatedStorage.SwordEquipped:FireServer()
    print("true")
    else
    equipped = false
    game.ReplicatedStorage.SwordUnEquipped:FireServer()
    print("false")

    end
end                

end)

server script -

local Bool = game.ReplicatedStorage:WaitForChild("Equipped") local sword = game.ServerStorage.Sword:Clone()

game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)

game.ReplicatedStorage.SwordEquipped.OnServerEvent:Connect(function()

    sword.Parent = character    
    local handle = sword:WaitForChild("WeldPart")


    local Weld = Instance.new("Weld", sword)
    Weld.Name = "Weld"
    Weld.Part0 = handle
        Weld.Part1 = character["Right Arm"]
        end)

game.ReplicatedStorage.SwordUnEquipped.OnServerEvent:Connect(function()

        sword:Destroy()

    end)
end)

end)

  1. errors/warnings/prints in the output- The Parent property of Sword is locked, current parent: NULL, new parent YellowFirecantdielol"

3 answers

Log in to vote
1
Answered by 3 years ago

Instead of destroying the sword, try parenting the sword to nil.

0
worked YellowFirecantdielol 0 — 3y
0
If it helped, accept my answer so I can get them sweet, sweet rep points. LeedleLeeRocket 1257 — 3y
Ad
Log in to vote
0
Answered by 3 years ago

oh yeah there is code parts that arent code blocks sorry it can be hard to read

0
you click that blue Lua icon when editing and put the code inside of the ~~~~~~~ to fix that imKirda 4491 — 3y
Log in to vote
0
Answered by
Hafrew 16
3 years ago

this works REMEMBER to put your ITEM in the STARTERPACK

------Keep this script in the StarterGui 
----delete all your other equip scripts plz @YellowFirecantdielol
--also this is a localscript

----Hafrew
local player = game.Players.LocalPlayer--playter
local UIS = game:GetService("UserInputService")--user imput service
local char = player.Character

game:GetService("StarterGui"):SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)

UIS.InputBegan:connect(function(input)
    if input.KeyCode == Enum.KeyCode.E then
        char.Humanoid:UnequipTools()
        wait(0.0001)
        char.Humanoid:EquipTool(player.Backpack:WaitForChild("sword name here"))
    end

end)


0
the other guy made it work YellowFirecantdielol 0 — 3y
0
oh Hafrew 16 — 3y

Answer this question