So recently I’ve been playing this game called ‘Valorant’ and I thought it would be cool to make an orb that reduces your vision and muffles surrounding audio to the people that are visible to the orb. I don’t have much experience in scripting but any ideas would help. Thanks!
You can change lighting for a player in a local script and add really dense fog. Because it is done in a local script, other players wont get affected by it. Same goes for muffling audio.
It’s a good idea to break it up into smaller problems, for example:
- Making the effect happen when the player makes specific inputs
- Making the 3D visual effects for the orb
- Making any 2D visual effects that appear for players being affected
- Detecting when a player should be affected by the effect
- Putting it all together
If you’d like help with any specific step then feel free to ask here or make another post
Hello and thanks for your reply. So I’ve decided to use raycasting to determine who should be blinded to that orb when seen. I’m not sure how to make a raycast that detects players within a 360 degrees range. I had searched for videos on how to do this but nothing really helped.
check the distance and then raycast from player head to the orb
you can get a vector for it by doing DestinationPosition - OriginPosition
you can then get the distance (length of vector) by doing vector.Magnitude
if the distance is too high or the raycast is interrupted then they shouldnt be considered visible
if you want it to be more accurate, you can do multiple raycasts towards different parts of the orb
So far I got this:
local Orb = game.Workspace.Orb.OrbMID
local Dist = 100
while wait(1) do
local target = nil
for i,v in pairs(game.Workspace:GetChildren()) do
local Human = v:FindFirstChild("Humanoid")
local Head = v:FindFirstChild("Head")
if Human and Head and Human.Health > 0 then
if (Head.Position - Orb.Position).Magnitude < Dist then
target = Head
end
end
end
end
I’m not sure on what to do next with using rays to change the players vision. Is there a specific position I should put a function in and what to do in that function?
You should do it from the client, loop through all the orbs
check the distance,
if the distance is good then do WorldRoot:Raycast()
if the Raycast isnt interuptted then apply audio & visual effects
once you know the player is looking at one orb, you can skip checking other orbs and just loop until the current orb is not being seen anymore (or it becomes too far) and thats when you will undo the visual & audio effects
You could add a blur effect to lighting to reduce there vision or a field of view effect this will make all player’s screens blurry and you can of course set the blurriness to your liking. For muffled audio you could use a lowpass filter.
First, add an EqualizerSoundEffect to your sound. This allows you to adjust the volume of certain frequencies of the sound. Notice the properties HighGain
and MidGain
. Slowly bring these down, and you should notice your audio becomes more “muffled.”
in order to insert these effects to could use a
touchedEvent
and then if the player touches the part you could then either add instances of the sounds and lighting effects (Remember if you go this route don’t forget to parent the lighting to the service or it will not work. an alternative method would be to add lighting effects to replicated storage and audio effects to replicated storage and then use a touched event. like this
local players = game.players.localplayer
local Character = game.Players.LocalPlayer.Character
local Humanoid = Character:FindFirstChild("Humanoid")
local Sound_Service = game.replicatedstorage.sound
local sound_Equalizer = game.sound
local Lighting = game.lighting
local Field_Of_View = game.lighting.replicatedstorage.FieldOfviewEffect
local Blur = Lighting.replicatedstorage.BlurEffect
local Orb = game.workspace.part
Orb.touched:Connect(function(hit)
if hit.Parent = humanoid then
-- what you want to do when the orb has been touched
end)
end
Note(if you went the replicated storage route don’t forget to parent the lighting effects and sound effects in replicated storage to the lighting service or the services will not insert into the lighting)
Could you send a reference video as for what your desired effect looks like?
This is an example from the game:
When they are in range or visible to the orb (Within a long distance), their vision distance reduces and all surroundings is muffled.
This looks somewhat easy, you just need to locally add a dense purple fog, and if you want to add some more pizzaz you could also animate a vignette.
As for the sound, do you want all sound muffled or just a muffled sound?
All sound muffled if there is a way to do that in a single event.
Yup! That’s pretty easy, ROBLOX has things called “SoundGroups” which is basically an instance you can link sound effects to, and any changes to that instance will reflect on all the other sounds.
This is as easy as creating a SoundGroup, looping through all audio instances on the client then linking them to the SoundGroup. (sound.SoundGroup).
Once you’ve done that it’s as easy as putting equalizer and making the audio muffled. (I believe you’d just turn the bass up and treble down, for a good sound effects you’ll just hvae to play around to see)
Thanks so much. Ill try this in a minute after I’m done with my raycasting code.
I just came across the issue where I can not change the RGB value of the atmosphere and the raycasting code just randomly thinks that there is an object blocking the ray from getting to my torso.
local Orb = script.Parent
local aggroDist = 100
local Atmos = game.Lighting.Atmosphere
while wait(1) do
local target = nil
for i,v in pairs(game.Workspace:GetChildren()) do
local Human = v:FindFirstChild("Humanoid")
local Torso = v:FindFirstChild("Torso")
if Human and Torso and Human.Health > 0 then
if (Torso.Position - Orb.Position).Magnitude < aggroDist then
local bulletRay = Ray.new(Orb.Position, (Torso.Position - Orb.Position).Unit*500)
local hit, position = game.Workspace:FindPartOnRayWithIgnoreList(bulletRay, {Orb})
if hit == Torso then
target = Torso
wait(0)
Atmos.Density = 1
Atmos.Offset = 0
else
wait(0)
Atmos.Density = 0.3
Atmos.Offset = 0.25
print("Something Is Blocking")
end
end
end
end
end
Let’s slow down for a quick second, what are you ray-casting for again?
To detect whether a player is visible to the orb or not (I am using the torso for this). If they are, the blind code will run. The only issue is is that it keeps on cutting off and on.
So like this?
Where player A is visible to the orb, where as player B isn’t.
Yes that would be correct.
EXTRA CHARACTERS IGNORE THIS…