How to turn my player character into an Npc character?

My proximityprompt requires you to hold it down for 0.5 seconds or something. Thats why Im not using ProximityPrompt.Triggered

1 Like

Change your NoobKit to ReplicatedStorage.

2 Likes

I moved the folder from ServerStorage to ReplicatedStorage and changed ServerStorage to ReplicatedStorage. Same error :confused:

Workspace.Shop.Noob Kit.Kit NPC.ProximityPrompt.Script:25: attempt to index nil with 'HumanoidRootPart'

1 Like

Move the stuff to its original place, and try this:

local prompt = script.Parent

prompt.TriggerEnded:Connect(function(player)

	print(player)

	local gamePassId = 22080195 -- Gamepass ID here

	local userId = player.userId

	if game:GetService(("MarketplaceService")):UserOwnsGamePassAsync(userId,gamePassId) == false then

		print("Player Does Not Have Gamepass")

		game:GetService("MarketplaceService"):PromptGamePassPurchase(player, gamePassId)

	else

		print("Player Has Gamepass")

		local character = player.Character
		character.Archivable = true
		
		local clone = character:Clone()

		clone.HumanoidRootPart.CFrame = CFrame.new(character.HumanoidRootPart.Position)

		local newcharLocation = game:GetService("ServerStorage").KitClones.NoobKit

		local newchar = newcharLocation:Clone()

		newchar.Parent = workspace

		newchar.Name = player.Name

		player.Character = newchar

		player.Character.HumanoidRootPart.CFrame = CFrame.new(clone.HumanoidRootPart.Position)

	end

end)

I think you have to set the character archivable to true. The character archivable property is set to false by default.

2 Likes

script error:

Workspace.Shop.Noob Kit.Kit NPC.ProximityPrompt.Script:42: Expected ')' (to close '(' at line 3), got <eof>

You must have accidentally deleted " ) ".

Script
local prompt = script.Parent

prompt.TriggerEnded:Connect(function(player)

	print(player)

	local gamePassId = 22080195 -- Gamepass ID here

	local userId = player.userId

	if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(userId,gamePassId) == false then

		print("Player Does Not Have Gamepass")

		game:GetService("MarketplaceService"):PromptGamePassPurchase(player, gamePassId)

	else

		print("Player Has Gamepass")

		local character = player.Character
		character.Archivable = true

		local clone = character:Clone()

		clone:WaitForChild("HumanoidRootPart").CFrame = CFrame.new(character:WaitForChild("HumanoidRootPart").Position)

		local newcharLocation = game:GetService("ServerStorage").KitClones.NoobKit

		local newchar = newcharLocation:Clone()

		newchar.Parent = workspace

		newchar.Name = player.Name

		player.Character = newchar

		player.Character:WaitForChild("HumanoidRootPart").CFrame = CFrame.new(clone:WaitForChild("HumanoidRootPart").Position)

	end

end)
1 Like

Okay so good news, it works, but…:


that might have been an error by me, but the character is unmovable.

Hmm… Maybe the HumanoidRootPart is anchored. I made it unanchored in the new script.

New Script
local prompt = script.Parent

prompt.TriggerEnded:Connect(function(player)

	print(player)

	local gamePassId = 22080195 -- Gamepass ID here

	local userId = player.userId

	if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(userId,gamePassId) == false then

		print("Player Does Not Have Gamepass")

		game:GetService("MarketplaceService"):PromptGamePassPurchase(player, gamePassId)

	else

		print("Player Has Gamepass")

		local character = player.Character
		character.Archivable = true

		local clone = character:Clone()

		clone:WaitForChild("HumanoidRootPart").CFrame = CFrame.new(character:WaitForChild("HumanoidRootPart").Position)

		local newcharLocation = game:GetService("ServerStorage").KitClones.NoobKit

		local newchar = newcharLocation:Clone()

		newchar.Parent = workspace

		newchar.Name = player.Name

		player.Character = newchar

		player.Character:WaitForChild("HumanoidRootPart").CFrame = CFrame.new(clone:WaitForChild("HumanoidRootPart").Position)
		player.Character:WaitForChild("HumanoidRootPart").Anchored = false
	end

end)

If the character works to move, but the animation doesn’t, you sometimes just have to disable the animation script inside the player and re-enable it.

1 Like

I can move the character now but I have two problems:

  1. Animation doesn’t work
  2. Camera is anchored
New Script
local prompt = script.Parent

prompt.TriggerEnded:Connect(function(player)

	print(player)

	local gamePassId = 22080195 -- Gamepass ID here

	local userId = player.userId

	if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(userId,gamePassId) == false then

		print("Player Does Not Have Gamepass")

		game:GetService("MarketplaceService"):PromptGamePassPurchase(player, gamePassId)

	else

		print("Player Has Gamepass")

		local character = player.Character
		character.Archivable = true

		local clone = character:Clone()

		clone:WaitForChild("HumanoidRootPart").CFrame = CFrame.new(character:WaitForChild("HumanoidRootPart").Position)

		local newcharLocation = game:GetService("ServerStorage").KitClones.NoobKit

		local newchar = newcharLocation:Clone()

		newchar.Parent = workspace

		newchar.Name = player.Name

		player.Character = newchar

		player.Character:WaitForChild("HumanoidRootPart").CFrame = CFrame.new(clone:WaitForChild("HumanoidRootPart").Position)
		player.Character:WaitForChild("HumanoidRootPart").Anchored = false
		pcall(function()
			player.Character.Animate.Disabled = true
			player.Character.Animate.Disabled = false
		end)
	end

end)
LocalScript in StarterCharacterScripts
game.Workspace.CurrentCamera.CameraSubject = script.Parent:WaitForChild("Humanoid")
1 Like

i still get the same problems…

Does the camera work at least?
image

1 Like

Nope, camera is still stuck in one place - it doesnt follow the player.

Change the script to this, and move the LocalScript inside of the script, but make the LocalScript disabled:

local prompt = script.Parent

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)

	print(player)

	local gamePassId = 22080195 -- Gamepass ID here

	local userId = player.userId

	

		print("Player Has Gamepass")

		character.Archivable = true

		local clone = character:Clone()

		clone:WaitForChild("HumanoidRootPart").CFrame = CFrame.new(character:WaitForChild("HumanoidRootPart").Position)

		local newcharLocation = game:GetService("ServerStorage").KitClones.NoobKit

		local newchar = newcharLocation:Clone()

		newchar.Parent = workspace

		newchar.Name = player.Name

		player.Character = newchar

		player.Character:WaitForChild("HumanoidRootPart").CFrame = CFrame.new(clone:WaitForChild("HumanoidRootPart").Position)
		player.Character:WaitForChild("HumanoidRootPart").Anchored = false
		local LS = script:WaitForChild("LocalScript"):Clone()
		LS.Parent = player.Character
		LS.Disabled = false
		pcall(function()
			player.Character.Animate.Disabled = true
			player.Character.Animate.Disabled = false
		end)
	end)	

end)
1 Like

try parent last
player.Character = newchar
newchar.Parent = workspace

just to fix camera

:sweat_smile:

1 Like

ummm i got this error:
Maximum event re-entrancy depth exceeded for Player.CharacterAdded

and…


i started off as the character and my spawn was so far away…

Oh- oops. I must’ve mixed up my testing script with yours…

Change script to this:

Script
local prompt = script.Parent

prompt.TriggerEnded:Connect(function(player)

	print(player)

	local gamePassId = 22080195 -- Gamepass ID here

	local userId = player.userId

	if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(userId,gamePassId) == false then

		print("Player Does Not Have Gamepass")

		game:GetService("MarketplaceService"):PromptGamePassPurchase(player, gamePassId)

	else

		print("Player Has Gamepass")

		local character = player.Character
		character.Archivable = true

		local clone = character:Clone()

		clone:WaitForChild("HumanoidRootPart").CFrame = CFrame.new(character:WaitForChild("HumanoidRootPart").Position)

		local newcharLocation = game:GetService("ServerStorage").KitClones.NoobKit

		local newchar = newcharLocation:Clone()

		newchar.Parent = workspace

		newchar.Name = player.Name

		player.Character = newchar

		player.Character:WaitForChild("HumanoidRootPart").CFrame = CFrame.new(clone:WaitForChild("HumanoidRootPart").Position)
		player.Character:WaitForChild("HumanoidRootPart").Anchored = false
		local LS = script:WaitForChild("LocalScript"):Clone()
		LS.Parent = player.Character
		LS.Disabled = false
		pcall(function()
			player.Character.Animate.Disabled = true
			player.Character.Animate.Disabled = false
		end)
	end

end)

But, besides… Did everything else work?

1 Like

yayyyy it works now, except for animation

Can you show me the inside of the NPC character when you’re not testing? The animation script could be missing…

1 Like

I realised that mistake earlier so I copied my character’s animate script into the npc:
image
doesnt work tho…

p.s. the humanoidrootpart error is gone in R15 i just tried :smiley: