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

StarterCharacter Gamepass can someone help?

I need help. Im trying to make a gamepass so when a player buys it they turn into a starter character i made. But the script im using rn is not working

local gamepassid = 10797682 local market = game:GetService("MarketplaceService") game.Players.PlayerAdded:Connect(function(plr) plr.CharacterAdded:Connect(function(char) if market:UserOwnsGamePassAsync(plr.UserId,gamepassid) then game.Players.LocalPlayer.Character = game.ServerStorage.StarterCharacter else --so if they dont own it game.Players.LocalPlayer.Character = game.ServerStorage.RedSkin --normal character

end end) end)

I added that script into ServerScript Service and idk if i need a remote function im just a beginner on scripting.

1 comment

0

Hey please check this out (https://scriptinghelpers.org/help/how-post-good-questions-answers) and scroll down to formatting! It'll help us read your code and be more efficient when assisting you

1 answer

✓ Accepted answer

Here you go, I hope this helps you.

local GamepassId = (10797682)

local Players = game:GetService("Players")
local MarketplaceService = game:GetService("MarketplaceService")
local ServerStorage = game:GetService("ServerStorage")
local GamepassStarterCharacter = ServerStorage.StarterCharacter

local GamepassFunction = function(Player)
	if not Player:IsA("Player") then
		return
	end
	Player.CharacterAdded:Connect(function(Character)
		local function LoadCharacter(Path)
			for i,v in pairs(Character) do
				v:Destroy()
			end
			for i,v in pairs(Path:GetChildren()) do
				v:Clone().Parent = Character
			end
			if not Character:FindFirstChildOfClass("Humanoid") then
				Instance.new("Humanoid",Character)
			end
		end
		if MarketplaceService:UserOwnsGamePassAsync(Player.UserId,GamepassId) then
			LoadCharacter(GamepassStarterCharacter)
		else
			LoadCharacter(ServerStorage.RedSkin)
		end
	end)
end

for i,v in pairs(Players:GetPlayers()) do
	GamepassFunction(v)
end
Players.PlayerAdded:Connect(GamepassFunction)

Make sure all the joints, anchors and scripts are available for your characters to work.

10 comments

0

I put the script and the startercharacter into serverstorage also i did put the script into serverscriptservice and it didn't work. Did i do something wrong? Again

0

I think the script is correct but i think my placement in roblox studio in incorrect. I only have A startercharacter in ServerStorage because the script you gave me said "ServerStorage.RedSkin" so i asummed that you needed to put the starter character into the serverstorage. And also i put the script into ServerScriptService and i have no remote functions or folders.

0

Errors i got "ServerScriptService.GamepassStarterCharacter:14: invalid argument #1 to 'pairs' (table expected, got Instance)" because my starter character was named "RedSkin" so i changed it to StarterCharacter. But even tho if i keep named RedSkin it gives my this error "StarterCharacter is not a valid member of ServerStorage" Just if u needed more details im trying to fix it myself.

0

My bad, line 14 should say 'for i,v in pairs(Character:GetChildren()) do'

0

Make sure the character is not anchored.

0

it worked im invis and i cant move

0

and its not anchored idk whats happening

0

uhhh let me try something

0

not sure why this isn't working, your best bet is probably just to clear out the clothing and stuff and apply models and stuff to the character through the script

0

i dont know it did nothing and everything is unanchored what else could be the problem?

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