I am trying to make code that has a block that disappears when you get closer to it. Right now, it works fine. It disappears when I’m close and reappears when I’m far. However, If I use HD admin restore map command, it stops working. I’ve searched to see if there was a way to run a script after a restore map command has been used, but I’ve found nothing on that either. I also have 4 blocks I’m trying to make disappear and I have no idea how to condense it to one script so it’s 4 scripts for now. I’ve tried making it remember scripts through the HD Admin backup thing but that didn’t work either.
Here’s my code:
local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local Part = workspace.neonbricc1
local Offset = 400
while true do
local Distance = Player:DistanceFromCharacter(Part.Position)
if Distance then
Part.Transparency = (-1 + (Distance - Offset) / 10)*-1
if Part.Transparency < 0 then
Part.Transparency = 0
end
end
wait()
end
local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local Offset = 400
while true do
local Distance = Player:DistanceFromCharacter(Part.Position)
local Part = workspace:FindFirstChild("neonbricc1")
if Distance and Part then
Part.Transparency = (-1 + (Distance - Offset) / 10)*-1
if Part.Transparency < 0 then
Part.Transparency = 0
end
end
task.wait()
end
This didn’t seem to work, before or after restoring the map.
I swapped line 8 and 7 and now it works before the map restore, but not after.
Oh woops I didnt notice the distance required the part because I was writing the solution on mobile
Is there any other solution that you can think of since it still only works before the map gets restored.
After the restoration process, is the part still inside of workspace?
Because I don’t see why this will not work, unless the part is deleted, name changed or the script stops running altogether.
Yeah, the bricks are still there after the restore. I’m not great at coding but my best guess is that the script runs when the server starts and then loops, but the restore breaks the loop. I still don’t know how I would get it not to break the loop though.
local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local Offset = 400
while true do
local Part = workspace:FindFirstChild("neonbricc1")
if Part then
local Distance = Player:DistanceFromCharacter(Part.Position)
Part.Transparency = (-1 + (Distance - Offset) / 10)*-1
if Part.Transparency < 0 then
Part.Transparency = 0
end
end
task.wait()
end
I think this should fix it.
It works! Thank you for helping me
1 Like
Hey man I’m not sure if you know the answer to this, but is there a way to disable the HDAdminMapBackup? It’s really messing with Highlights in my game and I need it gone. I’ve tried messaging the admin creator on twitter and tried looking through settings but nothing. Thanks a lot.
HD Admin is really old and has lots of deprecated functions, I’d recommend switching.
1 Like
What would you recommend? I was using Scripth’s Admin for years and then an exploit ruined it, so I’m not sure what to use anymore. I need something that supports custom commands, and ideally a private server creation command.
Adonis, It has lot of stuff, including datastore backups and client logging.
2 Likes