Hello everyone! I am making a script that gives a player a trail when their player/character joins the game! When the player oofs, or has to reset the script just doesn’t work. There are no errors in the output and the trail doesn’t appear, it also doesn’t even make the attachments in the players character! The Vip label works fine tho, also I know there are some spelling errors in the script! Here is the script -
Thanks to anyone who can help out!
2 Likes
Is the variable “MarketPlace” defined? As in your code I don’t see MarketPlace being defined at all. If so, just change at the very beginning of your code to,
local MarketPlace = game:GetService("MarketPlaceService")
If that is defined already I just don’t see it. Along with that the variable “VipId” doesn’t seem to be defined as well. If that’s the case just locate your gamepass and copy and paste it’s id from the topbar.
Those are above the script, Yes!
He said the VipLabel worked correctly, plus there are no errors so everything is defined. The issue is somewhere with the attachments and trails.
My mistake I misread what was happening, I had trails in one of my games and this issue happened as well. How I got around this might not be the best solution as I was still just starting out with coding, was using the Humanoid.Died function, in your code inside your CharacterAdded function you can define the humanoid as
local humanoid = char:WaitForChild("Humanoid")
-- then when the player dies
humanoid.Died:Connect(function()
Then you can make a function to run the same code as when the character is loaded.
you might want to add a wait() or some other form of confirming the player finished re-spawning or the code will execute while the player is still in the process of respawning
I will try this out! Thanks! Would I add this function in the playeradded or character or outside of both functions?
Edit: nvm u did char:WaitForChild(“Humanoid”) so character added
What you could do is instead of running the code both times you could create a function outside of the playeradded event, essentially,
local function trailGiver(character) -- use the character as a parameter
end
Then use the same exact code as inside the characteradded event. So when the player joins instead do
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(char)
trailGiver(char)
local humanoid = char:WaitForChild("Humanoid")
humanoid.Died:Connect(function()
-- put some form of time keeping to confirm when the player re-spawns
trailGiver(char)
end)
end)
end)
Again this might not be the most efficent way of doing this as I’m looking over some of my older code but based off of your situation this should work as a start/base.
Well I tried adding a wait before making the attachments and thats all it took! I didnt have to do anything else! Thanks for the idea of a wait, cant believe I didnt think of that!
I’m pretty new to scripting so that may be why, I’m trying to make this game with no watching yt for free code. lol
Thanks for the help @Notrealac0unt! The problem has been solved by adding a wait!