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)

5 comments
does the script itself not work or it's morphing you but shows the error sometimes
if it works and the error bothers you you should do if Root then to check if the HumanoidRootPart exists
It doesn't work.
It doesn't morph me, it just sends an error.
oh im blind change plr:FindFirstChild to character:FindFirstChild, plr is the one in Players, character is the one in Workspace