When I drop my tool on the conveyor and it comes into contact with the teleport component, I want it to be transferred. However, it does not appear to teleport my Tool when dropped. It only appears to operate when the tool model is already at the conveyor and not in the backpack.
Here is my script:
script.Parent.ClickDetector.MouseClick:Connect(function(player)
local backpack = player:WaitForChild("Backpack")
local character = player.Character or player.CharacterAdded:Wait()
local Item = backpack:FindFirstChild("Tool",true) or character:FindFirstChild("Tool",true)
if Item then
Item.Parent = script.Parent
Item:FindFirstChild("Handle").CFrame = script.Parent.Conveyor.CFrame + Vector3.new(0,3,0)
--Make sure that everything is held together
for _, part in ipairs(Item:GetDescendants()) do
if(part:IsA("BasePart") or part:IsA("MeshPart")) then
part.CanCollide = true
end
end
--
end
end)
It doesn’t show any error.
My 2nd Script:
local partToLookFor = game.Workspace.NPCsci.Teleporters.A
local TeleportPosition = CFrame.new(game.Workspace.NPCsci.Teleporters.B.Position)
--
--[[
game.Players.PlayerAdded:Connect(function(player)
local backpack = player:WaitForChild("Backpack")
if backpack then
local Part = backpack:WaitForChild("Suitcase").detect
if Part then
Part.Touched:Connect(function(hit)
if hit == partToLookFor then
Part.CFrame = TeleportPosition
end
end)
else
print("Part is equal to nil")
end
else
print("Backpack is equal to nil")
end
end)
]]
game.Players.PlayerAdded:Connect(function(player)
local suitcase = script.Parent.Tool.detect
suitcase.Touched:Connect(function(hit)
print("test")
if hit == partToLookFor then
suitcase.CFrame = TeleportPosition
end
end)
end)
I can’t find a topic similar to my topic but I hope someone will help me to fix this, Thank you!