Hi i currently have a script which gives player their trail when they click equip.
But when they die they have to re equip it?
Is their any way to resolve this?
local MarketPlaceService = game:GetService("MarketplaceService")
local player = game:GetService("Players").LocalPlayer
local RainbowpassID = 86294878
local ItemFrame = script.Parent.Frame.ScrollingFrame
local Trail = game.ReplicatedStorage["RainbowTrail"] -- Don't Put Serverstorage as client can't access serverstorage
wait(player.Character:WaitForChild("HumanoidRootPart"))
local success, hasPass = pcall(function() -- Changing the pcall to the correct format
return MarketPlaceService:UserOwnsGamePassAsync(player.UserId, RainbowpassID)
end)
if success then -- Checking if successful
if hasPass then -- Checking if the player has the
local clone = script.Parent.Frame.ScrollingFrame.sample:Clone()
clone.ImageLabel.Image = "http://www.roblox.com/asset/?id="..10939695942
clone.Parent = script.Parent.Frame.ScrollingFrame
clone.Visible = true
clone.Equipped.Visible = false
local equip = clone.Equip
local clicks = 0
equip.MouseButton1Click:Connect(function(equipped)
clone.Equipped.Visible = true
clicks += 1
local character = player.Character
task.wait()
local Head = character:FindFirstChild('Head') -- will wait until the head is loaded, at that time the code below will be yielded by this function, using waitforchild on something that doesnt exist will yield infinitely
local Torso = character:FindFirstChild('Torso')
local LowerTorso = character:FindFirstChild('LowerTorso') -- both has waistbackattachment
local plrTrail = Trail:Clone()
if Torso then
plrTrail.Parent = Torso
plrTrail.Attachment1 = Torso.WaistBackAttachment
elseif LowerTorso then
plrTrail.Parent = LowerTorso
plrTrail.Attachment1 = LowerTorso.WaistBackAttachment
plrTrail.Attachment0 = Head.FaceFrontAttachment
print("Hello1")
end
clone.Equipped.MouseButton1Click:Connect(function(unequip)
clicks = 0
plrTrail:Destroy()
clone.Equipped.Visible = false
end)
end)
end
end