I wanted to make a proximity prompt where if you hold it down, your character will turn into another character (basically a kit system). I did not know how to do this so I did some research on Devforum and found this post which helped me a bit. However, it was a bit confusing and I ended up with an error:
Workspace.Shop.Noob Kit.Kit NPC.ProximityPrompt.Script:25: attempt to index nil with 'HumanoidRootPart'
Here is my script:
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
local clone = character:Clone()
clone.HumanoidRootPart.Position = character.HumanoidRootPart.Position
local newchar = game:GetService("ServerStorage").KitClones.NoobKit
character = newchar
character.HumanoidRootPart.Position = newchar.HumanoidRootPart.Position
end
end)
Any help on how to fix this error and/or achieve what I want to achieve would be greatly appreciated. Thanks.
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
local clone = character:Clone()
clone.HumanoidRootPart.Position = 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.Position = clone.HumanoidRootPart.Position
end
end)
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
local clone = character:Clone()
clone.HumanoidRootPart.Position = 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.Position = clone.HumanoidRootPart.Position
end
end)
How about clone:WaitForChild('HumanoidRootPart'). If the output is infinite yield try to look yourself the hrp inside the explorer from server or client side, if its really there.