Tunnells
(PlaySage)
#1
So i have a module for a static effect for the users screen but it doesnt disappear when i want it too.
local Visuals = {}
local TweenService = game:GetService("TweenService")
local tweenInfo1 = TweenInfo.new(1)
local Textures = {
268592485,
268592462,
268592427,
268590007,
}
function Visuals.Static(StaticSound, StaticImage)
while true do
wait(0)
local RandomN = math.random(1,#Textures)
TweenService:Create(StaticSound, tweenInfo1, {Volume = 1}):Play()
TweenService:Create(StaticImage, tweenInfo1, {BackgroundTransparency = 0.7})
TweenService:Create(StaticImage, tweenInfo1, {ImageTransparency = 0.58}):Play()
local picked_value = Textures[RandomN]
StaticImage.Image = "http://www.roblox.com/asset/?id="..picked_value
end
end
function Visuals.UnStatic(StaticSound, StaticImage)
TweenService:Create(StaticSound, tweenInfo1, {Volume = 0}):Play()
TweenService:Create(StaticImage, tweenInfo1, {BackgroundTransparency = 1}):Play()
TweenService:Create(StaticImage, tweenInfo1, {ImageTransparency = 1}):Play()
end
return Visuals
Module
Tool.Equipped:Connect(function()
print("TOOOL")
Module.Static(Gui.Sounds.Static,Gui.StaticFrame)
Tool.Unequipped:Connect(function()
Module.UnStatic(Gui.Sounds.Static,Gui.StaticFrame)
print("out")
end)
end)
Local script.
Why is it wrapped in a while true do
loop? That’s NOT needed!
local Visuals = {}
local TweenService = game:GetService("TweenService")
local tweenInfo1 = TweenInfo.new(1)
local Textures = {
268592485,
268592462,
268592427,
268590007,
}
function Visuals.Static(StaticSound, StaticImage)
local RandomN = math.random(1,#Textures)
TweenService:Create(StaticSound, tweenInfo1, {Volume = 1}):Play()
TweenService:Create(StaticImage, tweenInfo1, {BackgroundTransparency = 0.7})
TweenService:Create(StaticImage, tweenInfo1, {ImageTransparency = 0.58}):Play()
local picked_value = Textures[RandomN]
StaticImage.Image = "http://www.roblox.com/asset/?id="..picked_value
end
function Visuals.UnStatic(StaticSound, StaticImage)
TweenService:Create(StaticSound, tweenInfo1, {Volume = 0}):Play()
TweenService:Create(StaticImage, tweenInfo1, {BackgroundTransparency = 1}):Play()
TweenService:Create(StaticImage, tweenInfo1, {ImageTransparency = 1}):Play()
end
return Visuals
Tunnells
(PlaySage)
#3
Its in a loop so that the image keep changing so it isnt one idle image.
Bad code, bad use, in a hurry written from mobile. I don’t suggest using while … do loops, and spawn.
local Visuals = {}
local TweenService = game:GetService("TweenService")
local tweenInfo1 = TweenInfo.new(1)
local Textures = {
268592485,
268592462,
268592427,
268590007,
};
local Changing = false;
function Visuals.Static(StaticSound, StaticImage) Changing = true;
spawn(function() while Changing do wait()
local RandomN = math.random(1,#Textures)
local picked_value = Textures[RandomN]
StaticImage.Image = "http://www.roblox.com/asset/?id="..picked_value
end; end)
TweenService:Create(StaticSound, tweenInfo1, {Volume = 1}):Play()
TweenService:Create(StaticImage, tweenInfo1, {BackgroundTransparency = 0.7})
TweenService:Create(StaticImage, tweenInfo1, {ImageTransparency = 0.58}):Play()
end
function Visuals.UnStatic(StaticSound, StaticImage) Changing = false
TweenService:Create(StaticSound, tweenInfo1, {Volume = 0}):Play()
TweenService:Create(StaticImage, tweenInfo1, {BackgroundTransparency = 1}):Play()
TweenService:Create(StaticImage, tweenInfo1, {ImageTransparency = 1}):Play()
end
return Visuals
1 Like