Clone not working for the second time

so i have a glider system that when you press the G key it deploys a glider, it works when doing it for the first time but after pressing the key again it wont give the glider, theres prob something wrong with the cloning bit cus i dont understand how cloning fully works.

so heres the scripts:
LOCAL SCRIPT STARTER CHARACTER SCRIPTS

local RS = game:GetService("ReplicatedStorage")
local UIS = game:GetService("UserInputService")
local SG = game:GetService("StarterGui")

local Event = RS.GuiderRemote
local Event2 = RS.GuiderRemote2

local Open = false
local Debounce = false

UIS.InputBegan:Connect(function(Key,IsTyping)
if IsTyping then return end
if Key.KeyCode == Enum.KeyCode.G and Open == false and Debounce == false then
Open = true
Debounce = true
Event:FireServer()
SG:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)
wait(5)
Debounce = false
elseif Key.KeyCode == Enum.KeyCode.G and Open == true and Debounce == false then
Open = false
Debounce = true
Event2:FireServer()
SG:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, true)
wait(5)
Debounce = false
 end
end)

SERVER SCRIPT:

local RS = game:GetService("ReplicatedStorage")
local CS = game:GetService("CollectionService")

local Guider = RS.Glider["Wind  Guider"]:Clone()
local Event = RS.GuiderRemote
local Event2 = RS.GuiderRemote2

Event.OnServerEvent:Connect(function(plr)
local Hum = plr.Character:FindFirstChildOfClass("Humanoid")
if Hum then
Guider.Parent = plr.Backpack
Hum:EquipTool(Guider)
  end
end)

Event2.OnServerEvent:Connect(function(plr)
local Hum = plr.Character:FindFirstChildOfClass("Humanoid")
if Hum then
Hum:UnequipTools()
Guider:Destroy()
  end
end)

really appreciate any help i can get, Thank you very much.

You are only cloning the tool once, so you basically destroy it forever.

This line is correct in the fact that it is cloning the model, but you only assign this variable once. Instead, place this within your OnServerEvent.

Move it to above this line would be good.

Additionally, you will now lose the reference for the destroy event, so what you should do is refind the tool in the backpack and destroy it.

1 Like

Thank you very much! it worked.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.