Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Can you script a "Premium Only" Trail?

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

Any help is appreciated,

Thank you!

2 comments

1

Please indent your code....

0

Your code is VERY messy without tabbing it. Please do, then we might be able to help you.

1 answer

✓ Accepted answer

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)
	

2 comments

0

Thank you so much! This really helped :)

0

glad

This discussion is preserved as it was. New answers, comments, and votes are closed.