-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCloud.lua
More file actions
118 lines (97 loc) · 3.01 KB
/
Copy pathCloud.lua
File metadata and controls
118 lines (97 loc) · 3.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local Workspace = game:GetService("Workspace")
local player = Players.LocalPlayer
local CONFIG = {
Transparency = 1,
PlatformThickness = 0.5,
PlatformPrefix = "LocalCloudPlatform__",
DynamicClouds = false,
}
local cloudFolder = Instance.new("Folder")
cloudFolder.Name = "LocalCloudPlatforms"
cloudFolder.Parent = Workspace
local cloudPlatforms = {}
local platformConnections = {}
local function isCloudPart(part)
if not part:IsA("BasePart") then
return false
end
if string.sub(part.Name, 1, #CONFIG.PlatformPrefix) == CONFIG.PlatformPrefix then
return false
end
return string.find(string.lower(part.Name), "cloud") ~= nil
end
local function updatePlatformTransform(cloudPart, platform)
platform.Size = Vector3.new(cloudPart.Size.X, CONFIG.PlatformThickness, cloudPart.Size.Z)
local offsetY = (cloudPart.Size.Y / 2) + (platform.Size.Y / 2)
platform.CFrame = cloudPart.CFrame * CFrame.new(0, offsetY, 0)
end
local function createPlatform(cloudPart)
if cloudPlatforms[cloudPart] then return end
local platform = Instance.new("Part")
platform.Name = CONFIG.PlatformPrefix .. cloudPart:GetDebugId()
platform.Anchored = true
platform.CanCollide = true
platform.Transparency = CONFIG.Transparency
platform.CastShadow = false
platform.Material = Enum.Material.SmoothPlastic
updatePlatformTransform(cloudPart, platform)
platform.Parent = cloudFolder
cloudPlatforms[cloudPart] = platform
if not CONFIG.DynamicClouds then
local connections = {}
table.insert(connections, cloudPart:GetPropertyChangedSignal("Size"):Connect(function()
if cloudPlatforms[cloudPart] then
updatePlatformTransform(cloudPart, platform)
end
end))
table.insert(connections, cloudPart:GetPropertyChangedSignal("CFrame"):Connect(function()
if cloudPlatforms[cloudPart] then
updatePlatformTransform(cloudPart, platform)
end
end))
platformConnections[cloudPart] = connections
end
end
local function removePlatform(cloudPart)
local platform = cloudPlatforms[cloudPart]
if platform then
local connections = platformConnections[cloudPart]
if connections then
for _, conn in ipairs(connections) do
conn:Disconnect()
end
platformConnections[cloudPart] = nil
end
platform:Destroy()
cloudPlatforms[cloudPart] = nil
end
end
if CONFIG.DynamicClouds then
RunService.RenderStepped:Connect(function()
for cloudPart, platform in pairs(cloudPlatforms) do
if not cloudPart or not cloudPart.Parent then
removePlatform(cloudPart)
else
updatePlatformTransform(cloudPart, platform)
end
end
end)
end
for _, obj in ipairs(Workspace:GetDescendants()) do
if isCloudPart(obj) then
createPlatform(obj)
end
end
Workspace.DescendantAdded:Connect(function(desc)
if isCloudPart(desc) then
createPlatform(desc)
end
end)
Workspace.DescendantRemoving:Connect(function(desc)
if cloudPlatforms[desc] then
removePlatform(desc)
end
end)
print("[LocalCloudStand] Activated. Standing platforms generated successfully!")