Hi, would anyone know how to make systeme like if a player touch a part , he got the Highlight effect
-Tnks
Hi, would anyone know how to make systeme like if a player touch a part , he got the Highlight effect
-Tnks
What highlight effect do you mean? I can help you create a Touch event though.
To basically create a touch event, what you do is:
part.Touched:Connect(function(hit)
if game.Players:GetPlayerFromCharacter(hit.Parent) then
-- code
end
end)
You get the event of the part being touched, make sure the part touching it can be identified as a player, and basically do your code from there.
Thanks but i already got the touch event
script.Parent.Touched:Connect(function(hit)
local h = hit.Parent.Humanoid
if h then
end
end)
i just dont know how to give the highlight effect
Alright so in order to give the highlight effect, just clone it and parent it to the HumanoidRootPart of the character.
You can do so by this:
script.Parent.Touched:Connect(function(hit)
local h = hit.Parent.Humanoid
if h then
local highlight = workspace.Dummy.Highlight:Clone() -- Just identify where the dummy is
highlight.Parent = hit.Parent.HumanoidRootPart
end
end)
it does not work ( is it not possible to just give like particle effect etc? )
What is the dummy parented to?
it is parented to the workspace
Oh, my fault.
script.Parent.Touched:Connect(function(hit)
local h = hit.Parent.Humanoid
if h then
local highlight = workspace.Dummy.Highlight:Clone() -- Just identify where the dummy is
highlight.Parent = hit.Parent
end
end)
Try doing this? Also what part is being touched? (Where do you have the script?)
Great it worked ! But how would you remove the effect if the player is not in the area anymore?
That’s a whole different topic, it depends what area you’re talking about. If its a region, I recommend looking into Region3 on youtube, and if the player is no longer in the Region, you can use the :Destroy()
function on the highlight
sorry i mean the part how can remove the effect if the player dont touch the part but if he re touch the part the player will got again the effect?
Oh, so basically you would create a connection or while loop to detect the player touching and not touching the part.
I’m just going to use the part’s events to keep it simple:
local debounce = false -- debounce is to add certain limits to an event or something occurring.
script.Parent.Touched:Connect(function(hit)
local h = hit.Parent.Humanoid
if h then
if not debounce then -- Determining if the debounce is set to false
debounce = true
local highlight = workspace.Dummy.Highlight:Clone() -- Just identify where the dummy is
highlight.Parent = hit.Parent
end
end
end)
script.Parent.TouchEnded:Connect(function(hit)
local h = hit.Parent.Humanoid
if h then
if debounce then -- If debounce is true
debounce = false
if hit.Parent:FindFirstChild("Highlight") then
hit.Parent.Highlight:Destroy()
end
end
end
end)
That workt !!! Thanks you dude !!!
No problem! Mark the answer as a solution if you found that best fitting as your solution.