#Script Help
19 messages · Page 1 of 1 (latest)
mhmm
anyways
local CollisionModule = {}
function CollisionModule.createCollisionGroup()
local group = {}
local hitters = {}
local colliders = {}
function group:addHitter(hitter, properties)
table.insert(hitters, hitter)
-- Add properties or logic specific to hitters
hitter.CanCollide = false -- Set CanCollide to false by default for GUI elements
end
function group:addCollider(collider, dynamic)
table.insert(colliders, collider)
-- Add properties or logic specific to colliders
end
function group:getHitters()
return hitters
end
function group:getColliders()
return colliders
end
return group
end
return CollisionModule
require(modulescript) in another script will give you what the modulescript returns
how do i link it to my script in screengui
** You are now Level 1! **
--- Variables
local UserInputService = game:GetService("UserInputService")
local TweenService = game:GetService("TweenService")
local Frame = script.Parent:WaitForChild("Frame")
local Player = Frame:WaitForChild("Player")
local Obstacles= game.ReplicatedStorage:WaitForChild("Obstacles")
--- Hide Core GUI
game:GetService("StarterGui"):SetCoreGuiEnabled(Enum.CoreGuiType.All, false)
--- Colisions
local Group = CollisionModule.createCollisionGroup()
Group:addHitter(Player, {})
Frame.ChildAdded:Connect(function(Obstacle)
Group:addCollider(Obstacle, true)
end)
local CanSpawn = true
Group:getHitter(1).CollidersTouched.Event:Connect(function(Hit)
if Hit then
TweenService:Create(Respawn, Info, {BackgroundTransparency = 0}):Play()
task.wait(0.75)
Player.Position = UDim2.new(0.2, 0, 0.5, 0)
for i, v in pairs(Frame:GetChildren()) do
if v.Name == "Obstacle" then
v:Destroy()
end
end
task.wait(0.75)
TweenService:Create(Respawn, Info, {BackgroundTransparency = 1}):Play()
end
end)
--- Player Control
UserInputService.InputBegan:Connect(function(Key)
local PosX = Player.Position.X
local PosY = Player.Position.Y
if Key.KeyCode == Enum.KeyCode.W and Player.Position ~= UDim2.new(PosX.Scale, 0, 0.1, 0) then
Player:TweenPosition(UDim2.new(PosX.Scale, 0, PosY.Scale - 0.4, 0), "Out", "Sine", 0.1, false)
end
if Key.KeyCode == Enum.KeyCode.S and Player.Position ~= UDim2.new(PosX.Scale, 0, 0.9, 0) then
Player:TweenPosition(UDim2.new(PosX.Scale, 0, PosY.Scale + 0.4, 0), "Out", "Sine", 0.1, false)
end
end)
--- Obstacles
if game.Loaded then
task.wait(3)
while task.wait(0.6) do
local ObsTable = {}
local RandomObs = Obstacles[math.random(1, #Obstacles:GetChildren())]
for i, v in pairs(RandomObs:GetChildren()) do
local Cloud = v:Clone()
Cloud.Position = UDim2.new(1.5, 0, Cloud.Position.Y.Scale, 0)
Cloud.ZIndex = 5
Cloud.Parent = Frame
local function Callback(State)
if State == Enum.TweenStatus.Completed then
Cloud:Destroy()
end
end
Cloud:TweenPosition(UDim2.new(-0.5, 0, Cloud.Position.Y.Scale, 0), "Out", "Linear", 3, false, Callback)
end
end
end
this is the script in my localscript
how am i supposed to link it
someone help
That literally is how you do it
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local CollisionModule = require(ReplicatedStorage.CollisionModule)
local Group = CollisionModule.createCollisionGroup()
print(Group:getHitters())