I have a working thermal vision system
The way it works is grouping the players locally to a folder that has a highlight instance in it
The problem is it needs to be constantly updated when a player dies and respawn via deactivating and activating the thermal vision again
What have you tried already?
Also could you post some code please.
you can make a script in SSS
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(char)
--add highlight here, give the created highlight a variable so it can be destroyed later.
plr.CharacterRemoving:Connect(function()
HighlightVariable:Destroy()
end)
end)
end)
Don’t do it like this, the CharacterRemoving connection is not cleaned up which means it will execute more and more.
Also, highlight instances have a limit of 31 highlight instances. The reason why OP put the player characters into folder was probably this.
Though the way you could really do this is like this:
--local or server script, doesn't matter.
local Players = game:GetService("Players")
local characterStorage = workspace:FindFirstChild("CharacterStorage") :: Model
if not characterStorage then
characterStorage = Instance.new("Model")
characterStorage.Name = "CharacterStorage"
characterStorage.Parent = workspace
end
local function onCharacterAdded(character: Model)
character.Parent = characterStorage
end
local function onPlayerAdded(player: Player)
player.CharacterAdded:Connect(onCharacterAdded)
end
Players.PlayerAdded:Connect(onPlayerAdded)
for _, player in Players:GetPlayers() do
onPlayerAdded(player)
end
And then from a local script simply do:
local highlight = Instance.new("Highlight")
highlight.Adornee = workspace:WaitForChild("CharacterStorage")
highlight.Parent = workspace
Here’s an example where pressing X disables/enables the thermal vision.
local UserInputService = game:GetService("UserInputService")
local highlight = Instance.new("Highlight") --you can also update this to get an existing highlight
highlight.Adornee = workspace:WaitForChild("CharacterStorage")
highlight.Parent = workspace
local isThermalVisionEnabled = highlight.Enabled
local function onInputBegan(input: InputObject, gameProcessed: boolean)
if gameProcessed then
return
end
if input.KeyCode == Enum.KeyCode.X then
isThermalVisionEnabled = not isThermalVisionEnabled
highlight.Enabled = isThermalVisionEnabled
end
end
UserInputService.InputBegan:Connect(onInputBegan)
My thermal vision system is working fine, i’ve already coded the parenting players to a highlight folder part
The main issue is whenever a new player joins the game or someone respawns it doesn’t parent them to the folder which it needs to be updated again via re-activating the thermal vision again
I could try to do “while vision something true do” but i figured that might crash the clients
Could you perhaps show the code so we can know what to fix?
Do i have to post the whole script?
Post the part of the script that is causing the issue
No no, it has no issue, by issue i mean how do i code a part where it parent newly loaded in characters/players to the highlight folder locally, it’s missing that