#Remote event part disappearance
291 messages · Page 1 of 1 (latest)
** You are now Level 6! **
You can achieve this with just a simple local script
Yeah thats a little confusing Lol
I mean like
On one persons screen once they see it and go close to it the part is now invisible/gone
and on the other persons screen they still see the part as it's a seperate thing for them
yeah just use a local script lol
it's a remote event?
no?
you dont need a remote event for that
Player 1 doesn't go up to the part so they still see it on their screen
Player 2 goes up to the part and they don't see it on their screen
Well
is it possible for it to be timed?
timed?
like the part show up at a certain time
not it being there forever until the player goes up to it
Im getting confused
also yo hello kash
Vincent do you mean you want a part's visibility to be relative to the player
And not the entire server?
Yes
deadass just realised you're from those developer event videos on youtube
good work man
Okay in that case yes just use a local script to check the part's distance
You dont need any remote events or anything
I appreciate it
do you want the part to be gone on a player screen when he is near it
Yeah
Its not a problem the first step to scripting is figuring out the problem and what it requires to solve it
Here ill give you a simple script to fix it
Do you want to learn coding or do you just want the code
local RunService = game:GetService("RunService")
local character = script.Parent
local root = character:WaitForChild("HumanoidRootPart")
--This is the part you want to make transparent
local part = workspace.Part
RunService.RenderStepped:Connect(function()
local distance = (part.Position - root.Position).magnitude
if distance <= minimumDistance then
part.Transparency = 1
else
part.Transparency = 0
end
end)
Put this script in StarterCharacterScripts
Youll have to change the part variable yourself
Both lol
Thanks kash
do you want the part to be gone or invisible?
Invisible
ah ok
alright bet, thanks
also @clever bay one last question
@clever bay you know that you didnt define minimumDistance
How would I make it on a cooldown so it only shows up on a certain time base?
Make a local script that calculates the distance between the part and the HumanoidRootPart of the player, and if a certain distance is met, change the transparency to 0.
The script works dw
Debounce in the script
Can I get more context on that
Which part
Oh whoops i wrote this on discord Lol
debounce
Make the script wait a certain amount of time before performing an aciton.
is it also possible to make it for a model and not a part?
Thank you
E.g.:
local debounce = false
local uis = game:GetService("UserInputService")
uis.InputBegan:Connect(function(input, gp)
if gp then return end
if debounce == false then
-- LOGIC
debounce = true
end
end)
In best of respect I have no idea what any of that means
Yes, you just have to use a for loop to loop through every part in the model and set it transparency to 0
When a player presses a button, the uis.InputBegan runs the function connected to it, checks if the player is currently typing in chat if gp then return end and if hes not, then it proceeds to check if the debounce value is set to false, if yes then it does its thing and after its done it sets debounce to true, so the process can go again.
No, you do not have to.
for _, v in iparis(yourModel:GetChildren()) do
v.Transparency = 0
end
What this does it it goes through every child in the model, and sets its transparency to 0
this may be too much information for him 💀
If you have something else than a part in your model, you better use a checkpoint if current child is in fact a part
yeah bro my brain isn't working
Look
for i , v - i stands for index, which is the order number and v stands for value, which is the specific part
just watch yt series on scripting:
https://www.youtube.com/watch?v=BkYwRdCukZA&list=PLhieaQmOk7nIfMZ1UmvKGPrwuwQVwAvFa
Beginner's Roblox Scripting Tutorial #1 - Roblox Studio Basics (Beginner to Pro 2019)
Link to Beginner's Tutorial Series:
https://www.youtube.com/playlist?list=PLhieaQmOk7nIfMZ1UmvKGPrwuwQVwAvFa
Link to download Roblox Studio:
https://www.roblox.com/create
Social Media:
https://twitter.com/realtapwater
https://instagram.com/realtapwater
New...
thanks bro
Model
Child1 -- A part
Child2 -- A bool value
Child3 -- another part
If your model looks like this and you run the function it will output as so
sergius this is too much for him
Model
Child1 -- i will be 1, v will be this part
Child2 -- i will be 2, v will be this specific bool value
Child3 -- i will be 3, v will be this specific part
example
i see
Is it @modest spruce
yes
these can be anything he tries to say
just a tad
I have been
thanks bro
wdym
the main reason for this thread
you want the code?
yes please bro
I don't usually do this but for you I will
But like, an NPC?
Yes
When the player gets too close to it, the NPC character dissapears?
yep
And it's a multiplayer game?
you want the Npc invisible or gone?
So it appears after some time?
Instead of dissapearing forever
should he reapear after a while or never been touched again
should he have collision when he is visible
local RunService = game:GetService("RunService")
local character = script.Parent
local root = character:WaitForChild("HumanoidRootPart")
local minimumDistance = 30
--This is the part you want to make transparent
local part = workspace.PutPartNameHere
part.CanCollide = false
RunService.RenderStepped:Connect(function()
local distance = (part.Position - root.Position).magnitude
if distance <= minimumDistance then
part.Transparency = 1
else
part.Transparency = 0
end
end)
ah
Aight
Will it have a face
Wtv
here
local rs = game:GetService("RunService")
local plr = game.Players.LocalPlayer
local char = script.Parent
local tooClose = false
local model = game.Workspace.Rig -- Change rig to your NPC model
local maxDis = 10 -- If player is closer than this many studs to the model, it dissapears
local maxTime = 5 -- How much time for the player has to be away in order for it to reappear
rs.Heartbeat:Connect(function()
local distance = (model.HumanoidRootPart.Position - char.HumanoidRootPart.Position).Magnitude
if distance < maxDis then
tooClose = true
for _, v in pairs(model:GetDescendants()) do
if v:IsA("MeshPart") or v.Name == "face" then
v.Transparency = 1
end
end
else
if tooClose == true then
task.wait(maxTime)
for _, v in pairs(model:GetDescendants()) do
if v:IsA("MeshPart") or v.Name == "face" then
v.Transparency = 0
end
end
tooClose = false
end
end
end)
Implemented it anyways
It works for me, so it should work for you
It's a local script in starterCharacter
Thank you, I'll check in just a moment
also thanks for the desc parts
I don't wanna sound crazy or what not but it's not working
at least for me
@sour lance
Did you put a local script in StarterCharacter and paste it in it?
And u changed the local model to your model?
local RunService = game:GetService("RunService")
local character = script.Parent
local root = character:WaitForChild("HumanoidRootPart")
local minimumDistance = 15
-- Reference the model you want to make transparent
local model = workspace.Dummy
local parts = model:GetDescendants()
RunService.RenderStepped:Connect(function()
local distance = (model.PrimaryPart.Position - root.Position).magnitude
for _, part in ipairs(parts) do
if part:IsA("BasePart") then
if distance <= minimumDistance then
part.Transparency = 1
part.CanCollide = false
end
elseif part:IsA("Decal") or part:IsA("Texture") then
-- Make Decals and Textures invisible
if distance <= minimumDistance then
part.Transparency = 1
end
end
end
end)
Try this and change the model = Workspeace.PutHereYourModel
Yeah
Local model is R6
I also did
Ooooohhh
Okay paste in this instead
local rs = game:GetService("RunService")
local plr = game.Players.LocalPlayer
local char = script.Parent
local tooClose = false
local model = game.Workspace.Rig -- Change rig to your NPC model
local maxDis = 10 -- If player is closer than this many studs to the model, it dissapears
local maxTime = 5 -- How much time for the player has to be away in order for it to reappear
rs.Heartbeat:Connect(function()
local distance = (model.HumanoidRootPart.Position - char.HumanoidRootPart.Position).Magnitude
if distance < maxDis then
tooClose = true
for _, v in pairs(model:GetDescendants()) do
if v:IsA("Part") or v.Name == "face" then
v.Transparency = 1
end
end
else
if tooClose == true then
task.wait(maxTime)
for _, v in pairs(model:GetDescendants()) do
if v:IsA("Part") or v.Name == "face" then
v.Transparency = 0
end
end
tooClose = false
end
end
end)
now it should 100% work
Yw
Not needed
He doesn't even have a face no more
oh ok
Is it possible to add a part to the rig and it still be fine?
like a part as a hat (random example)
yes
np
** You are now Level 10! **
level 10!!!
Like?
I just want it to be there really, I have a few ideas for it lol
but wdym?
Do you want it to go smoothly in and out
local rs = game:GetService("RunService")
local ts = game:GetService("TweenService")
local t1 = {}
t1.Transparency = 1
local t0 = {}
t0.Transparency = 0
local tInfo = TweenInfo.new(0.1, Enum.EasingStyle.Linear, Enum.EasingDirection.In, 0, false, 0)
local plr = game.Players.LocalPlayer
local char = script.Parent
local tooClose = false
local model = game.Workspace.Rig -- Change rig to your NPC model
local maxDis = 10 -- If player is closer than this many studs to the model, it dissapears
local maxTime = 5 -- How much time for the player has to be away in order for it to reappear
rs.Heartbeat:Connect(function()
local distance = (model.HumanoidRootPart.Position - char.HumanoidRootPart.Position).Magnitude
if distance < maxDis then
tooClose = true
for _, v in pairs(model:GetDescendants()) do
if v:IsA("Part") or v.Name == "face" then
if v.Name ~= "HumanoidRootPart" then
local tv = ts:Create(v, tInfo, t1)
tv:Play()
end
end
end
else
if tooClose == true then
task.wait(maxTime)
for _, v in pairs(model:GetDescendants()) do
if v:IsA("Part") or v.Name == "face" then
if v.Name ~= "HumanoidRootPart" then
local tv = ts:Create(v, tInfo, t0)
tv:Play()
end
end
end
tooClose = false
end
end
end)
It does, look at the video
Huh
Watch the full video
I have
it fades out and stays invisible for a few seconds
then it just shows again with no fade in scene
It does fade in
Cuh
Wait hodl on
what's up
I found a bug where it freaks out
oh shit lol
appreciate it though
Ive been helping others for hours now and didn't even tried to touch my own code
the respect though

like fr
Actually hold on, I think I have a better solution to this
this goes on and on lol
if its a local script only for the player
Local scripts execute only locally (duh) so that means it affects only the player
yeah
magic
As long as the parts you want to be invisile are Parts it will work
alr sweeet
if I change the head to a mesh that's also fine right
cause the head texture is wack
no
Yeah u just have to
uh
if v:IsA("Part") or v.Name == "face" or v:IsA("Mesh") then
add the v:IsA("Mesh")
there
ty
so it knows it has to hceck for meshes too
do i just add that above the end part?
uh
just add or v:IsA("Mesh") to both of them
so they look like this
and bam, the head dissapears aswell
alr
Thank you
not to be an absolute pain in the ass but would you be able to copy paste the code into it
I don't wanna ruin any of the code or what not (Wait nvm ty)
local rs = game:GetService("RunService")
local ts = game:GetService("TweenService")
local t1 = {}
t1.Transparency = 1
local t0 = {}
t0.Transparency = 0
local tInfo = TweenInfo.new(0.1, Enum.EasingStyle.Linear, Enum.EasingDirection.In, 0, false, 0)
local plr = game.Players.LocalPlayer
local char = script.Parent
local tooClose = false
local model = game.Workspace.Rig -- Change rig to your NPC model
local maxDis = 10 -- If player is closer than this many studs to the model, it dissapears
local maxTime = 5 -- How much time for the player has to be away in order for it to reappear
rs.Heartbeat:Connect(function()
local distance = (model.HumanoidRootPart.Position - char.HumanoidRootPart.Position).Magnitude
if distance < maxDis then
tooClose = true
for _, v in pairs(model:GetDescendants()) do
if v:IsA("Part") or v.Name == "face" or v:IsA("Mesh") then
if v.Name ~= "HumanoidRootPart" then
local tv = ts:Create(v, tInfo, t1)
tv:Play()
end
end
end
else
if tooClose == true then
task.wait(maxTime)
for _, v in pairs(model:GetDescendants()) do
if v:IsA("Part") or v.Name == "face" or v:IsA("Mesh") then
if v.Name ~= "HumanoidRootPart" then
local tv = ts:Create(v, tInfo, t0)
tv:Play()
end
end
end
tooClose = false
end
end
end)
thanks bro lol
yo @sour lance I've been trying to figure out a way to fix the mesh issue but anytime I tried changing the heads mesh it wont work
like the head mesh that I've added wont show up
my bad for the continue of this though
