I wanna reference humanoid from the tool that the script is in, and I also need the a way to be able to parent the script to workspace, without it being overwritten by the roblox default parent to backpack in the player
Visual example of what I need (When I press 1 on my keyboard its parented to workspace):
This is what I have so far:
local tool = script.Parent
local hum = script.Parent.Parent.Humanoid --humanoid isn't found because the tool is in serverstorage
local players = game:GetService("Players")
tool.Unequipped:Connect(function()
tool.Parent = workspace -- Doesn't work because the tool gets automatically get parented to backpack which overwrites this
tool.Handle.Position = hum.Position
tool.Handle.Anchored = true
end)
tool.Equipped:Connect(function()
tool.Handle.Anchored = false
end)
local tool = script.Parent
local handle = script.Parent:FindFirstChild("Handle")
local character
local humanoid
tool.Unequipped:Connect(function()
if character then
humanoid = character:WaitForChild("Humanoid")
end
local clone = tool:Clone()
tool:Destroy()
clone.Parent = workspace
clone:WaitForChild("Handle").CFrame = humanoid.CFrame * CFrame.new(0, 0, 10)
handle.Anchored = true
end)
tool.Equipped:Connect(function()
character = tool.Parent
handle.Anchored = false
end)