Hello! I have a script that is supposed to morph a player to ROBLOX package if they say a chat command, but I receive the error "UniformScript:14: attempt to index nil with 'CFrame'" Can anyone help?
My script:
local PlayerService = game:GetService("Players") local ChatService = game:GetService("Chat") local ServerStorage = game:GetService("ServerStorage") local Morphs = ServerStorage.Morphs PlayerService.PlayerAdded:Connect(function(plr) plr.Chatted:Connect(function(msg) if msg == "-uniform" then if plr.leaderstats.XP.Value > 35000 and plr.leaderstats.XP.Value < 85000 then local character = plr.Character local Root = plr:FindFirstChild("HumanoidRootPart") local MorphCharacter = Morphs:FindFirstChild("Guard"):Clone() MorphCharacter.HumanoidRootPart.CFrame = Root.CFrame plr.Character = MorphCharacter character:Destroy() MorphCharacter.Parent = workspace end end end) end)
You're looking for the HumanoidRootPart in the player, I think you meant to look for it in the player's Character.
local PlayerService = game:GetService("Players") local ChatService = game:GetService("Chat") local ServerStorage = game:GetService("ServerStorage") local Morphs = ServerStorage.Morphs PlayerService.PlayerAdded:Connect(function(plr) plr.Chatted:Connect(function(msg) if msg == "-uniform" then if plr.leaderstats.XP.Value > 35000 and plr.leaderstats.XP.Value < 85000 then local character = plr.Character local Root = character:FindFirstChild("HumanoidRootPart") local MorphCharacter = Morphs:FindFirstChild("Guard"):Clone() MorphCharacter.HumanoidRootPart.CFrame = Root.CFrame plr.Character = MorphCharacter character:Destroy() MorphCharacter.Parent = workspace end end end) end)