Plant bear trap to floor. [Simple]

I am going to feel like a idiot after this but

How do I make a beartrap go down to the floor?

Trap.Position = pos + Vector3.new(0,-1,0)

this doesnt work for me, it just stays the same position

What would be pos?

[Character limit]

Pos would be Tool.Handle.Position, so basically when ur holding the trap, thats where its going to drop

local Distance = 10 -- feel free to change!
local Tool =  -- reference tool here
local PartToReferenceFrom -- reference handle or whatever here
local Direction = -PartToReferenceFrom.CFrame.UpVector -- make sure your handle's top is facing rightsideup
local Ignore = {tool} -- stuff that the ray can pass through

local params = RaycastParams.New()
params.FilterType = Enum.RaycastFilterType.Blacklist
params.FilterDescendantsInstances = Ignore

local Ray = workspace:Raycast(PartToReferenceFrom.Position, Direction, params, distance)
if Ray ~= nil then
 Trap.Position = Ray.Position
end

You can use a surface selection to figure out if your handle is rightsideup, set it to Top and set the Adornee to the handle.
image

2 Likes

I tried it and it stays in the same spot, maybe there’s a problem i’m doing


function plant()
	if not debounce then
		debounce = true
		local vCharacter = Tool.Parent
		local vPlayer = game.Players:GetPlayerFromCharacter(vCharacter)
		local spawnPos = vCharacter.PrimaryPart.Position
		local Distance = 10 -- feel free to change!
		Trap = Instance.new("Part")
		Trap.Locked = true
		Trap.Size = Vector3.new(1.5, 0.5, 1.5)
		Trap.Name = "BearTrap"
		Trap.CanCollide = true
		Trap.Anchored = true
		
		local Tool = script.Parent
		local PartToReferenceFrom = Trap
		local Direction = -PartToReferenceFrom.CFrame.UpVector -- make sure your handle's top is facing rightsideup
		local Ignore = {Tool,vCharacter} -- stuff that the ray can pass through

		local params = RaycastParams.new()
		params.FilterType = Enum.RaycastFilterType.Blacklist
		params.FilterDescendantsInstances = Ignore

		local Ray = workspace:Raycast(PartToReferenceFrom.Position, Direction, params, Distance)
		if Ray ~= nil then
			Trap.Position = Ray.Position
		end
		
		local mesh1 = Tool.Handle.Mesh1:Clone()
		mesh1.Parent = Trap

		local creator_tag = Instance.new("ObjectValue")
		creator_tag.Value = vPlayer
		creator_tag.Name = "creator"
		creator_tag.Parent = Trap

		local stunsound = Tool.Cloned.Hurt:Clone()
		stunsound.Parent = Trap
		stunsound.Name = "Hurt"

		local stunsound2 = Tool.Cloned.Triggered:Clone()
		stunsound2.Parent = Trap
		stunsound2.Name = "Triggered"

		local trapscript = Tool.Cloned.BeartrapScript:Clone()
		trapscript.Parent = Trap
		trapscript.Disabled = false

		local mesh2 = Tool.Cloned.Mesh2:clone()
		mesh2.Parent = trapscript

		Trap.Parent = game.Workspace
		debounce = false
	end
end
-- Connections
Tool.Unequipped:Connect(function()
	if idle.IsPlaying then
		idle:Stop()
	end
end)

Events.Triggered.OnServerEvent:Connect(function(Player)
	if not triggered then
		triggered = true
		local Humanoid = Player.Character:WaitForChild("Humanoid")
		local PlaceAnimation = Humanoid:LoadAnimation(Animations.Place)
		PlaceAnimation:Play()
		Player.Character:WaitForChild("HumanoidRootPart").Anchored = true
		Sounds.SetUp:Play()
		wait(1.4)
		Sounds.Placedown:Play()
		wait(1.7)
		plant()
		Player.Character:WaitForChild("HumanoidRootPart").Anchored = false
		if Player:FindFirstChild("ToolSave")[Tool.Name].Value == true then
			Player:FindFirstChild("ToolSave")[Tool.Name].Value = false
		end
		if idle.IsPlaying then
			idle:Stop()
		end
		Tool:Destroy()
		triggered = false
	end
end)

Did you set the parent of the trap to workspace?

Try this:

if Ray ~= nil then
    Print(Ray.Position)
	Trap.Position = Ray.Position
end

It sets it after

I should probably do it before the ray

1 Like

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