Hello! So, I am trying to make a button system via Attributes feature. But, the tween is not working, I made sure the properties and attributes are right. I debugged via print() and made sure everything is working. (What I'm trying to do is make the crystal be white when touched.)
Here is the script:
local crystal = script.Parent local OutputON = crystal:GetAttribute("OutputON") local moduleSc = require(game.ReplicatedStorage.ModuleScript) crystal.Touched:Connect(function(h) if h.Parent:FindFirstChild("Humanoid") then crystal:SetAttribute("OutputON", true) local OutputON = crystal:GetAttribute("OutputON") moduleSc.crystalTurnOn(OutputON,crystal) end end)
Here is the module script:
local module = {} local ts = game:GetService("TweenService") module.crystalTurnOn = function(attribute,part) if attribute == true then local tweenInfo = TweenInfo.new( 7, Enum.EasingStyle.Linear, Enum.EasingDirection.In, 1, false, 5 ) local tween = ts:Create(part,tweenInfo,{Color = Color3.fromRGB(255, 255, 255)}) tween:Play() end end return module
Any help appreciated.
The only error is that you are returning an empty table when you call the module!
local module = {} -- empty table local ts = game:GetService("TweenService") module.crystalTurnOn = function(attribute,part) --calling an nil module and function if attribute == true then local tweenInfo = TweenInfo.new( 7, Enum.EasingStyle.Linear, Enum.EasingDirection.In, 1, false, 5 ) local tween = ts:Create(part,tweenInfo,{Color = Color3.fromRGB(255, 255, 255)}) tween:Play() end end return module -- returning the empty module
Here's how it should look.
local ts = game:GetService("TweenService") crystalTurnOn = function(attribute,part) if attribute == true then local tweenInfo = TweenInfo.new( 7, Enum.EasingStyle.Linear, Enum.EasingDirection.In, 1, false, 5 ) local tween = ts:Create(part,tweenInfo,{Color = Color3.fromRGB(255, 255, 255)}) tween:Play() end end return crystalTurnOn
Also, I'm not sure if you can tween a Color3. Good luck!