-
What do you want to achieve?
I’m making a round type game where the player spawns in a lobby and then teleports to a fighting arena after a certain amount of time. The players are given a sword which they can use to kill the other players in the arena but if the time runs out, they are teleported back to the lobby and their swords are removed from their inventory. -
What is the issue?
After two rounds the sword giving script breaks and I’m given this error The Parent property of ClassicSword is locked, current parent: NULL, new parent Backpack -
What solutions have you tried so far?
I’ve tried using Remove(), Destroy() and Debris but neither of them works.
Here is the code
LocalGiveSwordScript (ClientScript)
local InRound = game.ReplicatedStorage.InRound
local RepilcatedStorage1 = game:GetService("ReplicatedStorage")
local GiveSwordEvent = RepilcatedStorage1.RemoteGiveSwordEvent
InRound.Changed:Connect(function()
if InRound.Value == true then
GiveSwordEvent:FireServer()
end
end)
GiveSwordScript (ServerScript)
local RepilcatedStorage1 = game:GetService("ReplicatedStorage")
local Debris = game:GetService("Debris")
local GiveSwordEvent = RepilcatedStorage1.RemoteGiveSwordEvent
local Sword = RepilcatedStorage1.ClassicSword
local GiveSword = Sword:Clone()
GiveSwordEvent.OnServerEvent:Connect(function(player)
GiveSword.Parent = player.Backpack
end)
LocalDeleteSwordScript (ClientScript)
local RepilcatedStorage1 = game:GetService("ReplicatedStorage")
local DeleteSwordEvent = RepilcatedStorage1.RemoteDeleteSwordEvent
local InRound = game.ReplicatedStorage.InRound
InRound.Changed:Connect(function()
if InRound.Value == false then
DeleteSwordEvent:FireServer()
end
end)
DeleteSwordScript (ServerScript)
local RepilcatedStorage1 = game:GetService("ReplicatedStorage")
local DeleteSwordEvent = RepilcatedStorage1.RemoteDeleteSwordEvent
DeleteSwordEvent.OnServerEvent:Connect(function()
for i, player in pairs(game.Players:GetPlayers()) do
local character = player.Character
if not character then
else
if player.Backpack:FindFirstChild("ClassicSword") then
player.Backpack.ClassicSword:Destroy()
end
if character:FindFirstChild("ClassicSword") then
character.ClassicSword:Destroy()
end
end
end
end)
PS: I’m very new to programming and this is my first ever topic so any help possible would be
greatly appreciated.