Obby path not working

So I made obby and I have like a path that you can walk on when you click, but when you click it spawn above your head but it have to spawn under character:

Here is the model:

image

“PUT THIS IN THE WEAPON” script:

local debounce = false

function getPlayer(humanoid) 
local players = game.Players:children() 
for i = 1, #players do 
if players[i].Character.Humanoid == humanoid then return players[i] end 
end 
return nil 
end 

function onTouch(part) 

local human = part.Parent:findFirstChild("Humanoid") 
if (human ~= nil) and debounce == false then

debounce = true

local player = getPlayer(human) 

if (player == nil) then return end 

script.Parent:clone().Parent = player.Backpack

wait(2)
debounce = false
end
end


script.Parent.Parent.Touched:connect(onTouch) 

“Local Gui” script:

bin = script.Parent

function onKeyDown(key,mouse) 
key:lower() 
if key == "r" then
e = game.Workspace:GetChildren()
for i=1,#e do
if e[i].className == "Part" then
if e[i].Name == "Ice" then
if e[i]:findFirstChild("creator")~=nil then
if e[i].creator.Value == script.Parent.Parent.Parent then
e[i]:remove()
end
end
end
end
end
elseif key == "n" then
e = game.Workspace:GetChildren()
for i=1,#e do
if e[i].className == "Part" then
if e[i].Name == "Ice" then
e[i]:remove()
end
end
end

end
end

function press(mouse)
if sel == true then
hit = mouse.Target
local point = mouse.Hit.p
s = Instance.new("Part")
s.CanCollide = true 
s.Size=Vector3.new(6,2,18)
s.Anchored = true
s.BrickColor = BrickColor.new("White")
s.Transparency = 0.3
s.Name = "Ice"
s.TopSurface = "Smooth"
s.BottomSurface = "Smooth"
s.Parent = game.Workspace
c = script.CleanUp:clone()
c.Disabled = false
c.Parent = s
s.CFrame = CFrame.new(script.Parent.Parent.Parent.Character.Head.Position)
s.CFrame = CFrame.new(script.Parent.Parent.Parent.Character.Torso.Position.x,script.Parent.Parent.Parent.Character.Torso.Position.y-4,script.Parent.Parent.Parent.Character.Torso.Position.z)
s.CFrame = CFrame.new(s.Position,point)
r = Instance.new("ObjectValue")
r.Value = script.Parent.Parent.Parent
r.Parent = s
r.Name = "creator"
wait()
press(mouse)
end
end


function onButton1Down(mouse)
sel = true
if sel == true then
hit = mouse.Target
local point = mouse.Hit.p
s = Instance.new("Part")
s.CanCollide = true 
s.Size=Vector3.new(5,2,17)
s.Anchored = true
s.BrickColor = BrickColor.new("White")
s.Transparency = 0.3
s.Name = "Ice"
s.TopSurface = "Smooth"
s.BottomSurface = "Smooth"
s.Parent = game.Workspace
c = script.CleanUp:clone()
c.Disabled = false
c.Parent = s
s.CFrame = CFrame.new(script.Parent.Parent.Parent.Character.Head.Position)
s.CFrame = CFrame.new(script.Parent.Parent.Parent.Character.Torso.Position.x,script.Parent.Parent.Parent.Character.Torso.Position.y-5,script.Parent.Parent.Parent.Character.Torso.Position.z)
s.CFrame = CFrame.new(s.Position,point)
r = Instance.new("ObjectValue")
r.Value = script.Parent.Parent.Parent
r.Parent = s
r.Name = "creator"
wait()
hit = mouse.Target
local point = mouse.Hit.p
s = Instance.new("Part")
s.CanCollide = true 
s.Size=Vector3.new(5,2,17)
s.Anchored = true
s.BrickColor = BrickColor.new("White")
s.Transparency = 0.3
s.Name = "Ice"
s.TopSurface = "Smooth"
s.BottomSurface = "Smooth"
s.Parent = game.Workspace
c = script.CleanUp:clone()
c.Disabled = false
c.Parent = s
s.CFrame = CFrame.new(script.Parent.Parent.Parent.Character.Head.Position)
s.CFrame = CFrame.new(script.Parent.Parent.Parent.Character.Torso.Position.x,script.Parent.Parent.Parent.Character.Torso.Position.y-4,script.Parent.Parent.Parent.Character.Torso.Position.z)
s.CFrame = CFrame.new(s.Position,point)
r = Instance.new("ObjectValue")
r.Value = script.Parent.Parent.Parent
r.Parent = s
r.Name = "creator"
wait()
hit = mouse.Target
local point = mouse.Hit.p
s = Instance.new("Part")
s.CanCollide = true 
s.Size=Vector3.new(5,2,15)
s.Anchored = true
s.BrickColor = BrickColor.new("White")
s.Transparency = 0.3
s.Name = "Ice"
s.TopSurface = "Smooth"
s.BottomSurface = "Smooth"
s.Parent = game.Workspace
c = script.CleanUp:clone()
c.Disabled = false
c.Parent = s
s.CFrame = CFrame.new(script.Parent.Parent.Parent.Character.Head.Position)
s.CFrame = CFrame.new(script.Parent.Parent.Parent.Character.Torso.Position.x,script.Parent.Parent.Parent.Character.Torso.Position.y-6,script.Parent.Parent.Parent.Character.Torso.Position.z)
s.CFrame = CFrame.new(s.Position,point)
r = Instance.new("ObjectValue")
r.Value = script.Parent.Parent.Parent
r.Parent = s
r.Name = "creator"
press(mouse)
end
end


function onButton1Up(mouse)
sel = false
end

function onEquippedLocal(mouse)

	if mouse == nil then
		print("Mouse not found")
		return 
	end

	mouse.Icon = "rbxasset://textures\\GunCursor.png"
	mouse.Button1Down:connect(function() onButton1Down(mouse) end)
	mouse.Button1Up:connect(function() onButton1Up(mouse) end)
	mouse.KeyDown:connect(onKeyDown) 
e = script.Parent.Parent.Parent:GetChildren()
for i=1,#e do
if e[i].className == "Hint" then
e[i]:remove()
end
end
s = Instance.new("Hint")
s.Parent = script.Parent.Parent.Parent
s.Text = "click R to reset all your ice you made and Hold mouse to create a stream of ice"
end

function unsel(mouse)
e = script.Parent.Parent.Parent:GetChildren()
for i=1,#e do
if e[i].className == "Hint" then
e[i]:remove()
end
end
end


script.Parent.Selected:connect(onEquippedLocal) 
script.Parent.Deselected:connect(unsel)

“CleanUp” script in “Local Gui” script:

wait(0.1)
script.Parent:remove()

If someone know what is problem, I would appreciate their help. Tysm.

2 Likes

You need to replace all words “Torso” on “LowerTorso”

1 Like

Actually I don’t have to do anything I just have to put characters on R6, but tysm.

1 Like

This is irrelevant to the solution but I recommend properly naming your variables and tabbing your code so it is much more easier to read and edit.

1 Like

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