what’s wrong with duplicating the walls and trees and things?
Wow, that is really close to what I am trying to do
can u hide behind all the items in workspace?
Could you use MoveTo() to move the player behind the wall??
currently, yeah
don’t mind these extra words here
2 Likes
How would I make CFrame.lookAt() only affect the X and Z axis? I had this trouble with a script a while ago
When they hit h, raycast in several directions. If the raycast hits something close, use AlignPosition to move their CFrame to the correct location.
Also, it would be CFrame.lookAt(v3(p), v3(p2.X, player.Character.hrp.Position.Y, p2.Z))
here is a simple script (change it however you want)
local players = game:GetService("Players")
local userInputService = game:GetService("UserInputService")
local player = players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("humanoid")
local itemHolder = workspace --where all the items are stored
local maxDistance = 5 --minimum distance to be able to click E
for _ , v in pairs(workspace:GetChildren()) do --you can use GetDescendants() (if you want)
if v:IsA("BasePart") or v:IsA("MeshPart") then --checking if it's a part
local difference = (player.Character.PrimaryPart.Position - v.Position).Magnitude --difference between player and part
userInputService.InputBegan:Connect(function(input , gameProcessed)
if difference > maxDistance then return end
if gameProcessed then return end
if input.KeyCode == Enum.KeyCode.E then
humanoid:MoveTo(v.Position , v)
end
end)
end
end