Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Can you script a "Premium Only" Trail?

Asked by 4 years ago
Edited 4 years ago

Hello, thank you for looking at my question. :)

I need to make a Trail (which I've already done) but make it so that only premium owners get it. Is it possible to make this script work?

--Script--

if game.Players.LocalPlayer.MembershipType == Enum.MembershipType.Premium then do
function Join(p)
local function Char(c)
local trail = script.Trail:Clone()
trail.Parent = c.Head
local A0 = Instance.new("Attachment",c.Head)
local A1 = Instance.new("Attachment",c.HumanoidRootPart)
A0.Name = "Attachment0"
A1.Name = "Attachment1"
trail.Attachment0 = A0
trail.Attachment1 = A1
end
p.CharacterAdded:connect(Char)
end
game.Players.PlayerAdded:connect(Join)
end

I've tried to edit it but I get given a error In my output tab saying:

Workspace.RainbowTrail:15: Expected 'end' (to close 'then' at line 1), got <eof>

Any help is appreciated,

Thank you!

1
Please indent your code.... Luka_Gaming07 534 — 4y
0
Your code is VERY messy without tabbing it. Please do, then we might be able to help you. Sensei_Developer 298 — 4y

1 answer

Log in to vote
1
Answered by
royaltoe 5144 Moderation Voter Community Moderator
4 years ago
Edited 4 years ago

If it's not already, the script needs to be a normal server Script, not a Localscript and it should be placed in the ServerScriptService

Your script also runs at the beginning of the game when the server is made. You should instead place your code inside a CharacterAdded event:

--create an event for when a player joins the game
game.Players.PlayerAdded:Connect(function(player)
    --create an event when the player's character is added
    --this will run whenever the player's character loads
    player.CharacterAdded:Connect(function(character)
        --if player is are premium, give them a trail
        if player.MembershipType == Enum.MembershipType.Premium then
            local trail = script.Trail:Clone()
            trail.Parent = character.Head
            local A0 = Instance.new("Attachment",character.Head)
            local A1 = Instance.new("Attachment",character.HumanoidRootPart)
            A0.Name = "Attachment0"
            A1.Name = "Attachment1"
            trail.Attachment0 = A0
            trail.Attachment1 = A1
        end
    end)
end)

0
Thank you so much! This really helped :) ROBLOX_sammy048 28 — 4y
0
glad royaltoe 5144 — 4y
Ad

Answer this question