Here Is The Script
local function makeXRayPart(part)
-- LocalTransparencyModifier will make parts see-through but only for the local
-- client, and it won't replicate to the server
part.LocalTransparencyModifier = .5
end
-- This function uses recursion to search for parts in the game
local function recurseForParts(object)
-- Did we find a part that isn't
if object:IsA("BasePart") then
makeXRayPart(object)
end
-- Stop if this object has a Humanoid - we don't want to see-through players!
if object:FindFirstChildOfClass("Humanoid") then return end
-- Check the object's children for more parts
for _, child in pairs(object:GetChildren()) do
recurseForParts(child)
end
end
recurseForParts(workspace)
I want To make it so it waits 7.5 seconds and then stops till you can use it again
Please Help
LargeHotDogs13
Outside of the function, make a debounce variable, set it to false
local debounce = false
then, define a new function
local function xRay(objects)
if not debounce then
debounce = true
recurseForParts(objects)
wait(7.5)
debounce = false
end
end
use xray function instead of recurseForParts when running
It Starts But It Doesnt stop
local debounce = false
script.Parent.MouseButton1Click:Connect(function()
local function makeXRayPart(part)
-- LocalTransparencyModifier will make parts see-through but only for the local
-- client, and it won't replicate to the server
part.LocalTransparencyModifier = .5
end
-- This function uses recursion to search for parts in the game
local function recurseForParts(object)
-- Did we find a part that isn't
if object:IsA("BasePart") then
makeXRayPart(object)
end
-- Stop if this object has a Humanoid - we don't want to see-through players!
if object:FindFirstChildOfClass("Humanoid") then return end
-- Check the object's children for more parts
for _, child in pairs(object:GetChildren()) do
recurseForParts(child)
end
end
local function xRay(objects)
if not debounce then
debounce = true
recurseForParts(objects)
wait(7.5)
debounce = false
end
end
xRay(workspace)
end)
1 Like
Have another function defined which puts the transparencies back to normal. Run the function after wait(7.5) statement