DistanceFade - A transparency falloff effect for your games

how can i add if player touch it, it kills them?

There’s a lot of ways to go about that, for something simple I’d look into the touched event BasePart | Documentation - Roblox Creator Hub

Yo, how to make continuous fireballs in the fireballs preset?

maybe just clone the model? if you want more functionality I’d make your own script, the forcefield template with the fireball is more of a showcase than something to actually use in your games so the codes a little bad lol

Amazing work. This will be perfect for any borders, or barriers.

1 Like

Edit: Nevermind, Putting in starterplayer fixes it. Chat I might be slow.

Hi! I love this resource I was actually the first one to comment.

I did have a question, or a problem I guess.

I made the script that runs the normal code a module script located in startercharacterscripts. Problem is that it will duplicate and add an extra face to the parts. Do you have any idea of how i can fix this or if i could take a different approach of how I handle this?.

Example:

local Borders = {}

--//Services
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RunService = game:GetService("RunService")
local TweenService = game:GetService("TweenService")
local Workspace = game:GetService("Workspace")


--//Modules
local Modules = ReplicatedStorage.Modules

local DistanceFade = require(Modules.Effects.VFX.DistanceFade)


--//Folders
local BorderFolder = Workspace.World.Map.Essential.Borders


--//Constructors
local NewDistanceFade = DistanceFade.new()


--//Tables
local Settings = {
	["EdgeDistanceCalculations"] = true,
	["Texture"] = "rbxassetid://18852900044",
	["TextureTransparency"] = .25,
	["BackgroundTransparency"] = 0.95,
	["TextureColor"] = Color3.fromRGB(115, 248, 255),
	["BackgroundColor"] = Color3.fromRGB(0, 153, 255),
	["TextureSize"] = Vector2.new(6, 5.5),
	["TextureOffset"] = Vector2.new(0, .5),
	["Brightness"] = 1,
}


local PartsToAdd = {
	BorderFolder:WaitForChild("1"),
	BorderFolder:WaitForChild("2"),
	BorderFolder:WaitForChild("3"),
	BorderFolder:WaitForChild("4"),
}

local BaseOffsetsX = {
	["1"] = 0,
	["2"] = 0,
	["3"] = 0,
	["4"] = 0,
	["5"] = 0,
	["6"] = 0,
	["7"] = 0,
}


--//UpdateSettings
NewDistanceFade:UpdateSettings(Settings)


--//AddFaces
for _,basePart in PartsToAdd do
	NewDistanceFade:AddFace(basePart, Enum.NormalId.Front)
	NewDistanceFade:AddFace(basePart, Enum.NormalId.Back)
end

--//Runservice
local TweenValue = Instance.new("Vector3Value")
TweenValue.Parent = script
TweenService:Create(TweenValue, TweenInfo.new(6, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, -1, false), { Value = Vector3.new(-6, 5.5) }):Play()

RunService.Heartbeat:Connect(function() 
	
	for _,v in PartsToAdd do
		local offsetX = BaseOffsetsX[v.Name]-- + tweenValue.Value.X
		local offsetY = TweenValue.Value.Y
		NewDistanceFade:UpdateFaceSettings(v, Enum.NormalId.Front, {["TextureOffset"] = Vector2.new(offsetX, offsetY)})
		NewDistanceFade:UpdateFaceSettings(v, Enum.NormalId.Back, {["TextureOffset"] = Vector2.new(-offsetX, offsetY)})
	end
	
	local NewSettings = {}
	
	NewDistanceFade:Step()
	
end)

return Borders

Module location(Name is “Borders”):
image

Problem Example:

Every death it stacks an extra face. Im gonna cry dude

2 Likes

This module is actually really cool!
i also actually did a quick edit of the module so that it cant be used from a server script (only downside is that you have the specify the player when running the addface and step functions)

its still unfortunate that it dosent work with multiple parts as that would make it 10x better, i may look through the module and try to work with it, but im not that good at this type of scripting so i may be out of luck, but ill post back if i get any results!

well, i got some sort of progress but it’s having weird effects due to me not completley understanding the code myself, but what i suggest is having some sort of link system
(for instance like a string used as a key)
so each string can link with different positions

the current code i have

local DistanceFade = require(game.ReplicatedStorage.DistanceFade) -- or wherever the module is located
local distanceFadeObj = DistanceFade.new() --initialize the object
local plr = game.Players.LocalKarura
local partToAdd = workspace:WaitForChild("Part") -- can be any BasePart


distanceFadeObj:AddFace(partToAdd, Enum.NormalId.Front,plr,"sus") -- can add to any face, in this case the front and back of the part
distanceFadeObj:AddFace(partToAdd, Enum.NormalId.Back,plr,"sus")

distanceFadeObj:AddFace(partToAdd, Enum.NormalId.Front,plr,"hi") -- can add to any face, in this case the front and back of the part
distanceFadeObj:AddFace(partToAdd, Enum.NormalId.Back,plr,"hi")

game:GetService("RunService").Heartbeat:Connect(function()
	local targetPos = script.Parent:WaitForChild("HumanoidRootPart").Position -- the position the effect is centered around
	distanceFadeObj:Step(targetPos,plr,"hi") -- if parameter is nil, automatically targets local character's root part
	distanceFadeObj:Step(workspace:WaitForChild("eeee").Position,plr,"sus") -- if parameter is nil, automatically targets local character's root part
end)

“hi” is whats linked to the players HRP
and “sus” is linked to a part in workspace

if i figured out how the module works i may be able to get it working, but due to me not being experienced in modules, im kind of stuck. if you do end up updating this (witch i doubt)
perhaps this could be a way to have multiple position work!

1 Like

I actually did the thing! tho it may be a bit confusing to work with, im sure it can be simplified by someone who understands modules more than me,

The thingy.rbxm (17.6 KB)
Heres the file!

feel free to ask any questions or whatever, and of course all credit to the guy who made it in the post above as i only added this dumb key system to make it work with multiple parts,
But enjoy!

2 Likes

i made a version of the script that tracks ANY BasePart with the “ForcefeildTrack” tag
(may be a little messy as i was messing around with things)
ScriptWorky (StarterPlayerScripts).lua (3.1 KB)

1 Like

Tnx man. Definietly doing a youtube video abt this one lol. its FASCINATING!

Can we have a wally of this? It would be nice