Tool Part Does Not Appear

Sorry for the late response, but I’ve found the issue. When you place a script or tool, such as you are doing (into a model in replicatedstorage), it unloads the script. When you place it back into the players backpack, it will reload the script and cause it to error because at the start, yes the part did exist, but now its in serverstorage and doesn’t exist anymore.

Try this:

-- Made by xuN8
-- Last updated May 27, 2021

-- Stuff in here is just for the special effects; go to Client script for the main code
-- For quick modifications, check the tool properties for attributes

local TweenService = game:GetService('TweenService')
local tool = script.Parent

local identifier = tool:FindFirstChild("PartIdentifier")
if not identifier then
	identifier = Instance.new('ObjectValue', tool)
	identifier.Name = "PartIdentifier"
	identifier.Value = tool.CarpetPart
end

local Triggered = tool.Triggered
local carpetPart = identifier.Value
local sonicBoom = carpetPart.SonicBoomPart.SonicBoomEffect
local burst = carpetPart.Burst
local hrpOffset = carpetPart.RootPartOffset

local identifier = carpetPart:FindFirstChild("ToolIdentifier") or Instance.new('ObjectValue', carpetPart)
identifier.Name = "ToolIdentifier"
identifier.Value = tool

local tweenInfo = TweenInfo.new(0.5, Enum.EasingStyle.Cubic, Enum.EasingDirection.Out)
local sonicBoomTween = TweenService:Create(sonicBoom, tweenInfo, {Radius = 30, InnerRadius = 30})
-- this will be used to attach the carpetPart to the player character
local weld = Instance.new('Weld', carpetPart)

local function showCarpet(bool)
	burst.Enabled = false
	sonicBoom.Visible = false
	carpetPart.Parent = bool and tool or game.ServerStorage
end

local function onEquip()
	local character = tool.Parent
	local hrp = character:FindFirstChild('HumanoidRootPart')
	if not hrp then return end
	
	-- attach carpetPart to humanoid rootpart
	weld.Part1 = hrp
	weld.C0 = CFrame.new()
	weld.C1 = hrpOffset.CFrame:Inverse()
	weld.Enabled = true
	
	showCarpet(true)
end

local function onUnequip()
	weld.Enabled = false
	showCarpet(false)
end

local function onActivate()
	-- show effects
	burst.Enabled = true
	sonicBoom.Visible = true
	sonicBoom.InnerRadius = 0
	sonicBoom.Radius = 15
	-- play the sonic boom tween and wait for it to finish
	sonicBoomTween:Play()
	sonicBoomTween.Completed:Wait()
	-- hide effects
	burst.Enabled = false
	sonicBoom.Visible = false
end

tool.CircularProgress.Enabled = false
weld.Part0 = carpetPart
weld.Enabled = false
showCarpet(false)

if tool:GetAttribute('SonicBoom') then Triggered.OnServerEvent:Connect(onActivate) end
tool.Equipped:Connect(onEquip)
tool.Unequipped:Connect(onUnequip)

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