so i tried making a modulescript where whne the user clicks a gui button it shrinks right. i put it in replicatedstorage and called it UI_Animations. Then i tried requiring it form a localscript where i looped through the all the descendants of a screengui and whenever the player would press a gui button it would shrink. That was the plan. but then it gave me the error “Players.TobiElReyofficial758.PlayerGui.Frames.Shop.Frame.Buttongroup1.AnimateUI:9: attempt to call a nil value”
These are the scripts:
Modulescript:
local animations = {}
Click_Settings = {
length = 0.2,
EasingStyle = Enum.EasingStyle.Sine,
EasingDirection = Enum.EasingDirection.Out,
Size = 1.2,
}
function animations.onClick(button, group)
if button:FindFirstChild("Cooldown_Click").Value == false then
button:FindFirstChild("Cooldown_Click").Value = true
local info = {}
info.TweenInfo = TweenInfo.new(
Click_Settings.length,
Click_Settings.EasingStyle,
Click_Settings.EasingDirection,
0,
false,
0
)
info.ShrinkSize = UDim2.new(button.Size.X.Scale/Click_Settings.Size,0,button.Size.Y.Scale/Click_Settings.Size,0)
info.ShrinkTween = tweenService:Create(button, info.TweenInfo, {Size = info.ShrinkSize})
info.ShrinkTween:Play()
task.wait(0.5)
button:FindFirstChild("Cooldown_Click").Value = false
end
end```
localscript:
```local replicatedStorage = game:GetService("ReplicatedStorage")
local UI_Animations = require(replicatedStorage:WaitForChild('UI_Animations'))
task.wait(5)
for _, button in pairs(script.Parent:GetDescendants()) do
if button:IsA("GuiButton") then
button.MouseButton1Click:Connect(function()
UI_Animations.onClick(button, button.Parent, button.Parent.Parent)
end)
end
end```
any fixes?
it still dosen’t work it keeps saying "Key ‘onClick’ not found in table ‘Module3D’. i have no idea why.but it keeps saying that inside the localscript.
local animations = {}
local tweenService = game:GetService("TweenService")
Click_Settings = {
length = 0.2,
EasingStyle = Enum.EasingStyle.Sine,
EasingDirection = Enum.EasingDirection.Out,
Size = 1.2,
}
function animations.onClick(button)
if not button:FindFirstChild("Cooldown_Click") then
print("Cooldown_Click is not here")
end
if button:FindFirstChild("Cooldown_Click").Value == false then
button:FindFirstChild("Cooldown_Click").Value = true
local info = {}
info.TweenInfo = TweenInfo.new(
Click_Settings.length,
Click_Settings.EasingStyle,
Click_Settings.EasingDirection,
0,
false,
0
)
info.ShrinkSize = UDim2.new(button.Size.X.Scale/Click_Settings.Size,0,button.Size.Y.Scale/Click_Settings.Size,0)
info.ShrinkTween = tweenService:Create(button, info.TweenInfo, {Size = info.ShrinkSize})
info.ShrinkTween:Play()
task.wait(0.5)
button:FindFirstChild("Cooldown_Click").Value = false
end
end
return animations
Local Script:
local replicatedStorage = game:GetService("ReplicatedStorage")
local UI_Animations = require(replicatedStorage:WaitForChild('UI_Animations'))
task.wait(5)
for _, button in pairs(script.Parent:GetDescendants()) do
if button:IsA("GuiButton") then
button.MouseButton1Click:Connect(function()
UI_Animations.onClick(button)
end)
end
end
local UI_Animations = require(game.ReplicatedStorage.UI_Animations)
task.wait(5)
for _, button in pairs(script.Parent:GetDescendants()) do
if button:IsA("GuiButton") then
button.MouseButton1Click:Connect(function()
UI_Animations.onClick(button)
end)
end
end
I have change some lines in your module (is a test) can you test it:
local animations = {}
local tweenService = game:GetService("TweenService")
Click_Settings = {
length = 0.2,
EasingStyle = Enum.EasingStyle.Sine,
EasingDirection = Enum.EasingDirection.Out,
Size = 1.2,
}
function animations.onClick(button)
if not button:FindFirstChild("Cooldown_Click") then
print("Cooldown_Click is not here")
end
if button:FindFirstChild("Cooldown_Click").Value == false then
button:FindFirstChild("Cooldown_Click").Value = true
local info = {}
info.TweenInfo = TweenInfo.new(
Click_Settings.length,
Click_Settings.EasingStyle,
Click_Settings.EasingDirection,
0,
false,
0
)
tweenService:Create(button, info.TweenInfo, {Size = UDim2.new(button.Size.X.Scale/Click_Settings.Size,0,button.Size.Y.Scale/Click_Settings.Size,0)}):Play()
task.wait(Click_Settings.length)
button:FindFirstChild("Cooldown_Click").Value = false
end
end
return animations