I would recommend trying to write your own code (for various reasons), but here’s something that could help:
local part = --The part you have to be near
local plr = game.Players.LocalPlayer
local char = plr.Character
local root = char.PrimaryPart
while wait(0.1) do
local rootPos = root.Position
local partPos = part.Position
local distance = (rootPos - partPos).Magnitude
local requiredDistance = 10 -- Change this to however near you want the player to be for the camera to shake
if distance <= requiredDistance then
-- Enable your camera shake script here
end
end
This is the best I can do with the information you have given. I hope this helps, if you have any questions feel free to ask!
You could just make a box even flat if you liked. Lock it down and with full transparency.
Then take everything off but can touch … and drop a script like this in it.
local ftf = true
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
if ftf then ftf = false
-- hit.Parent would end up being the players cam to shake
task.wait(-- the shake time)
ftf = true
end
end
end)
This would save you the constant loop going.
Edit: added a bit more to that for a first time flag.
Did you set part = to your part? I think that’s probably your problem, I couldn’t really write anymore of the script for you, but if you show me your explorer I could maybe help more.