I Want to Achieve so When I touch the player the Trail Color Changes Keep it simple and clear!
Trail Color is not changing when I touch the player Include screenshots / videos if possible!
Yes I did Look for solutions on the dev hub Did you look for solutions on the Developer Hub?
-- game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(char)
while wait() do
local Teams = game:GetService("Teams")
if player.Team == Teams["Seeker"] then
local debounce = false
char:WaitForChild("HumanoidRootPart").Touched:Connect(function(hit)
local hum = hit.Parent:FindFirstChild("Humanoid")
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if hum then
if player then
if debounce == false then
debounce = true
wait(0.5)
player.Team = game.Teams.Seeker
hum.Parent.Head.Trail.Color = Color3.fromRGB(255,0,4)
print("Hit a player")
wait(1)
debounce = false
end
end
end
end)
end
end
end)
end)
--//Services
local Players = game:GetService("Players")
local Teams = game:GetService("Teams")
--//Variables
local Seeker = Teams:WaitForChild("Seeker")
--//Functions
local function InitializeSeeker(character)
local HumanoidRootPart = character:WaitForChild("HumanoidRootPart")
local debounce = false
HumanoidRootPart.Touched:Connect(function(hit)
if debounce then
return
end
local Player = Players:GetPlayerFromCharacter(hit.Parent)
if not Player then
return
end
debounce = true
task.wait(0.5)
Player.Team = Seeker
Player.Character.Head.Trail.Color = ColorSequence.new(Color3.fromRGB(255,0,4))
print("Hit a player")
task.wait(1)
debounce = false
end)
end
Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
if player.Team == Seeker then
InitializeSeeker(character)
end
player:GetPropertyChangedSignal("Team"):Connect(function()
if player.Team == Seeker then
InitializeSeeker(character)
end
end)
end)
end)