1IsTech
(M1nd1sS0ftw4r3)
June 6, 2023, 11:41am
#1
I created three module scripts, two of the module scripts store tween information, one of the module scripts store physical properties, but I don’t know how to store them all in a single module script.
First module script:
local tweenInfo = TweenInfo.new(
1,
Enum.EasingStyle.Sine,
Enum.EasingDirection.InOut,
0,
false,
0
)
return tweenInfo
Second Module Script:
local Density = 0.01
local Elasticity = 0.25
local ElasticityWeight = 1
local Friction = 0.4
local FrictionWeight = 1
local physicalProporties = PhysicalProperties.new(
Density,
Elasticity,
ElasticityWeight,
Friction,
FrictionWeight
)
return physicalProporties
Third Module Script:
local tweenInfo = TweenInfo.new(
0.1,
Enum.EasingStyle.Sine,
Enum.EasingDirection.InOut,
0,
false,
0
)
return tweenInfo
Any help is appreciated, thanks.
1 Like
CZXPEK
(czo)
June 6, 2023, 11:49am
#2
local Module = {}
Module.TweenInfo1 = TweenInfo.new(
1,
Enum.EasingStyle.Sine,
Enum.EasingDirection.InOut,
0,
false,
0
)
Module.TweenInfo2 = TweenInfo.new(
0.1,
Enum.EasingStyle.Sine,
Enum.EasingDirection.InOut,
0,
false,
0
)
Module.PhysProperties = PhysicalProperties.new(
0.01,
0.25,
1,
0.4,
1
)
return Module
then to get the tweeninfo from a normal script you just do:
local Module = require(path to module)
local Info = Module.TweenInfo1
1IsTech
(M1nd1sS0ftw4r3)
June 6, 2023, 11:51am
#3
This is the main script:
local TweenService = game:GetService("TweenService")
local Door1 = script.Parent:WaitForChild("Door1")
local Door2 = script.Parent:WaitForChild("Door2")
local GlassDoorConfigures = script.Parent:WaitForChild("GlassDoorConfigures")
local Touch = script.Parent:WaitForChild("Touch")
local tweenInformation = require(script.Parent.TweenInformation)
local setPhysicalProporties = require(script.Parent.SetPhysicalProporties)
local shatterTweenInformation = require(script.Parent.ShatterTweenInformation)
local debounce = false
GlassDoorConfigures.CanShatter:GetPropertyChangedSignal("Value"):Connect(function()
if GlassDoorConfigures.CanShatter.Value == true then
GlassDoorConfigures.ShatterChance.Value = math.random(1, 10)
elseif GlassDoorConfigures.CanShatter.Value == false then
GlassDoorConfigures.ShatterChance.Value = 0
end
end)
Touch.Touched:Connect(function()
if debounce == false and GlassDoorConfigures.ShatterChance.Value < 9 then
debounce = true
TweenService:Create(Door1.DoorPart, tweenInformation, {CFrame = script.Parent.OpenDoor1.CFrame}):Play()
TweenService:Create(Door2.DoorPart, tweenInformation, {CFrame = script.Parent.OpenDoor2.CFrame}):Play()
elseif debounce == false and GlassDoorConfigures.ShatterChance.Value > 9 then
debounce = true
TweenService:Create(Door1.DoorPart, shatterTweenInformation, {CFrame = script.Parent.ShatterDoor1.CFrame}):Play()
TweenService:Create(Door2.DoorPart, shatterTweenInformation, {CFrame = script.Parent.ShatterDoor2.CFrame}):Play()
wait(0.1)
Door1.DoorPart.CustomPhysicalProperties = setPhysicalProporties
Door2.DoorPart.CustomPhysicalProperties = setPhysicalProporties
Door1.DoorPart.Anchored = false
Door2.DoorPart.Anchored = false
end
end)
Touch.TouchEnded:Connect(function()
if debounce == true and GlassDoorConfigures.ShatterChance.Value < 9 then
debounce = false
TweenService:Create(Door1.DoorPart, tweenInformation, {CFrame = script.Parent.CloseDoor1.CFrame}):Play()
TweenService:Create(Door2.DoorPart, tweenInformation, {CFrame = script.Parent.CloseDoor2.CFrame}):Play()
end
end)
Here is a simple script to do what you want, try running the script, but note that I am unable to test it as I don’t have access to your work. Anyways, I want to remind you that I didn’t write this script in a studio environment, so there’s a possibility that it may not work as intended. Let me know if it’s not worked as intented. If i fixed the issue please make sure to close your support topic by check the solution.
You can also like to support
Script
local Module = require(script.ModuleScript)
local ModuleDensity1 = Module.secondModuleData.density
local ModuleElasticity2 = Module.secondModuleData.elasticity
local TweenInfo3 = Module.thirdModuleData.tweenInfo
print(ModuleDensity1)
print(ModuleElasticity2)
print(TweenInfo3)
print(TweenInfo3.RepeatCount)
Module
local Module = {}
Module.firstModuleData = {
tweenInfo = TweenInfo.new(
1,
Enum.EasingStyle.Sine,
Enum.EasingDirection.InOut,
0,
false,
0
)
}
Module.secondModuleData = {
density = 0.01,
elasticity = 0.25,
elasticityWeight = 1,
friction = 0.4,
frictionWeight = 1
}
Module.thirdModuleData = {
tweenInfo = TweenInfo.new(
0.1,
Enum.EasingStyle.Sine,
Enum.EasingDirection.InOut,
0,
false,
0
)
}
return Module
Test place
TestPlace.rbxl (42.4 KB)
1IsTech
(M1nd1sS0ftw4r3)
June 6, 2023, 12:05pm
#5
I’m still confused, why is a
local Module = {}
needed?
We put everything in this table then we return it when required.
1IsTech
(M1nd1sS0ftw4r3)
June 6, 2023, 12:20pm
#7
I get the error:
Unable to cast Dictionary to TweenInfo
The error is located in line 19 of the main script.
Show me the line you did, that must a Dictionary and not a simple line.
1IsTech
(M1nd1sS0ftw4r3)
June 6, 2023, 12:27pm
#9
TweenService:Create(Door1.DoorPart, moduleData.firstModuleData, {CFrame = script.Parent.OpenDoor1.CFrame}):Play()
Try that if that worked
Put script under Door1 and the module i gave to you under the script.
local TweenService = game:GetService("TweenService")
local Door1 = script.Parent
local Module = require(script.ModuleScript)
local ModuleDensity1 = Module.secondModuleData.density
local ModuleElasticity2 = Module.secondModuleData.elasticity
local TweenInfo3 = Module.thirdModuleData.tweenInfo
TweenService:Create(
Door1.DoorPart,
TweenInfo3,
{CFrame = script.Parent.OpenDoor1.CFrame}
):Play()
1IsTech
(M1nd1sS0ftw4r3)
June 6, 2023, 12:39pm
#11
Ok, it works now. thanks to you for solving.
Your welcome hope it help you for the futur.
system
(system)
Closed
June 20, 2023, 12:40pm
#13
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.