I just wanted to make a particle become enabled once the player touches a part. The thing is the particle emitter is inside one of the players parts. In this case the particle emitter that I want to become enabled is the “Yellow” particle emitter in the players head.
Here is the script that I have so far that is not giving me any errors but is not working.
local part = script.Parent
local player = game.Players.LocalPlayer.Character
part.Touched:Connect(function(hit)
if hit.Parent:FindFirstChildWhichIsA('Humanoid') then
player.Head.LowerBeak.Yellow.Enabled = true
wait(3)
player.Head.LowerBeak.Yellow.Enabled = false
end
end)
Hello, this is a local script. Use a script for the touched function.
local part = script.Parent
part.Touched:Connect(function(hit)
if hit.Parent:FindFirstChildWhichIsA('Humanoid') then
local character = game.Players:FindFirstChild(hit.Parent.Name)
-- do ur stuff here
end
end)
If you just want the particle emitter to apply to the client, use a remote event with the :FireClient(plr) function.
Thanks, but it doesn’t seem to be working. Its also not giving me any errors.
Here is what im using in a local script:
local part = script.Parent
part.Touched:Connect(function(hit)
if hit.Parent:FindFirstChildWhichIsA('Humanoid') then
local character = game.Players:FindFirstChild(hit.Parent.Name)
character.Head.LowerBeak.Yellow.Enabled = true
wait(3)
character.Head.LowerBeak.Yellow.Enabled = false
end
end)
What you need is to add a script (not local) into a part that you wish the player to touch just like @ItsRayQwQ said. You were on the right page with part.touched however, you do NOT need the local player for this. In the touched:Connect(Function(hit)), hit is a variable for whatever instance has touched the object. Assuming that the play will walk on the part, this would mean that the hit variable would be referencing to the foot of the user. The feet of any character is always a descendant of the character meaning that you can use hit.Parent to reference the players character. After all of that, you can write something along these lines
local part = script.Parent -- Assuming this script is in the part
part.touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then -- I may be wrong here
local Character = hit.Parent
Character.LowerBeak.Yellow.etc
end
end)