EDIT: I found a solution that worked. Look at answers
I'm trying to make a script to make the player climb when a part has an easily settable property, but it's not working. I'm so confused.
To clarify, I want to be able to have a variable be true when touching the parts, and false when not. This specifically has to work with every part, which could have the same name, material, or be in a folder.
I also want G to have to be pressed for it to work
This is the code I've got currently;
local plr = game.Players.LocalPlayer
local uis = game:GetService("UserInputService")
local gDown = false --pressing g or not
local wTouch = false --touching wall or not
local climb = false --climb false or not
local wall = workspace.Walls:GetChildren() --get the Walls folder's children
uis.InputBegan:Connect(function(key, isTyping) --get G key press
if key.KeyCode == Enum.KeyCode.G then
gDown = true
print("gdown true")
end
end)
uis.InputEnded:Connect(function(key, isTyping) -- lose G key press
if key.KeyCode == Enum.KeyCode.G then
gDown = false
print("gdown false")
climb = false
end
end)
wall.Touched:Connect(function(hit)--check when walls are touched (broken, the focus)
if hit.Parent:FindFirstChild("Humanoid") then
print("touching wall")
end
end)
If you don't have a fix for this but DO have a similar script that works close enough, PLEASE tell me. I want ANYTHING that could just get the result.
Priority is adding force. I can figure out orientation separately, if needed.

1 comment
I actually just found a solution that involved raycasts that worked extremely well, but thanks for the answer