Hey Devs! I am making a sleigh that spawns where your mouse is, where you are clicking, and despawns when you unequip it. Here is the code and the explorer down below.
local spawnable = script.Parent.Spawnable
script.Parent.Activated:Connect(function(player)
local mouse = player:GetMouse()
if spawnable == true then
local sleigh = game:GetService("ReplicatedStorage").Sleigh:Clone()
sleigh.CFrame = mouse.Hit.Position
spawnable = false
script.Parent.Unequipped:Connect(function()
sleigh:Remove()
end)
else
end
end)
The problem is that you are not actually moving the Sleigh into the games Workspace.
Only objects inside of your Workspace actually get rendered and have physics applied to them.
Cloned Instances will by default inherit the parent of the Instance that was cloned, which in your case means that the duplicated Sleigh is still inside of ReplicatedStorage. Setting your Sleighs Parent attribute to the games Workspace should fix your problem.
local spawnable = script.Parent.Spawnable
script.Parent.Activated:Connect(function(player)
local mouse = player:GetMouse()
if spawnable.Value == true then
spawnable.Value = false
local sleigh = game:GetService("ReplicatedStorage").Sleigh:Clone()
sleigh:PivotTo(CFrame.new(mouse.Hit.Position))
sleigh.Parent = workspace
script.Parent.Unequipped:Connect(function()
sleigh:Destroy()
end)
end
end)