However now I would like for only specific users to have the trail, and I am unsure on how to do this. I tried following a few other topics similar to mine, however the way they had their trails were different from mine. A little help to achieve this would be greatly appreciated!
Have a table storing all the userids for players that should have the trail. Then use table.find() to check if a player has the userId when they join, then give them the trail. I would also suggest that instead of a while loop to constantly move the emitter, just use a weldconstraint on it. Which is cleaner and reduces unnecessary script activity as well
local allowedUsers = {
84398600
}
local character = script.Parent.Parent
local player = game.Players:GetPlayerFromCharacter(character)
if table.find(allowedUsers,player.UserId) then
while wait(1) do
script.Parent.CFrame = script.Parent.Parent.HumanoidRootPart.CFrame
end
end
local allowedUsers = {
84398600,
552028399,
1234567890,
SomeOtherUserIds, --Remember to separate each of them with a comma
}
local character = script.Parent.Parent
local player = game.Players:GetPlayerFromCharacter(character)
if table.find(allowedUsers,player.UserId) then
script.Parent.ParticleEmitter.Parent = character:WaitForChild("HumanoidRootPart") --Much smoother and less laggy than doing it over and over again every second
end
There is no need to put them on the second line, but it looks better, and is easier to find mistakes. It is likely another problem, so you should give us any output errors that we need to fix.
It also might be some stupid mis-spelling that I accidentally made, which happens a lot when I’m not typing in studio, so any output errors would be useful.
Also, this script should be in a script, and not a local script, otherwise it will only appear for the client.
I’ve checked the logs and there is no error related to my trails. I’ve tried testing with me and my friend, changing who gets the trail and who doesn’t and it seems to work fine. Thank you for your help!