I’m making a chat command module (:kick, :heal) but the morph command is broken. It says it is unable to cast Instance to int64, which I looked into and made sure I didn’t interchange arguments. Anyways here’s the module script I’m using right now
local commandmodule = {}
local plrService = game:GetService("Players")
commandmodule.Commands = {
":kick",
":kill",
":heal",
":damage",
":plrMorph"
}
function commandmodule.morph(morphChar, ID)
local humDesc = plrService:GetHumanoidDescriptionFromUserId(ID)
humDesc.Parent = morphChar
end
function commandmodule.messaged(msg)
local splitstring = string.split(msg, " ")
local stringp1 = splitstring[1]
for i, v in pairs(commandmodule.Commands) do
local chosenCommand = commandmodule.Commands[i]
if stringp1 == chosenCommand then
if i == 1 then
local plrName = splitstring[2]
local reason = splitstring[3]
local findPlayer = plrService:FindFirstChild(plrName)
if findPlayer then
findPlayer:Kick("You have been kicked. Reason: " .. reason)
else
print("Error: Player cannot be found")
end
elseif i == 2 then
local plrName = splitstring[2]
local target = plrService:FindFirstChild(plrName)
if target then
local targetChar = target.Character
targetChar:WaitForChild("Humanoid").Health = 0
else
print("Error: Player cannot be found")
end
elseif i == 3 then
local plrName = splitstring[2]
local heal = splitstring[3]
local findPlr = plrService:FindFirstChild(plrName)
if findPlr then
local char = findPlr.Character
char:WaitForChild("Humanoid").Health += heal
else
print("Error: Player cannot be found")
end
elseif i == 4 then
local plrName = splitstring[2]
local dmg = splitstring[3]
local lookForPlayer = plrService:FindFirstChild(plrName)
if lookForPlayer then
local char = lookForPlayer.Character
char:WaitForChild("Humanoid").Health -= dmg
else
print("Error: Player cannot be found")
end
elseif i == 5 then
local plrName = splitstring[2]
local plrID = splitstring[3]
local lookForPlayer = plrService:FindFirstChild(plrName)
if lookForPlayer then
commandmodule:morph(lookForPlayer.Character, tonumber(plrID)) --Error begins here
lookForPlayer.CharacterAdded:Connect(commandmodule.morph(lookForPlayer.Character, tonumber(plrID)))
lookForPlayer:LoadCharacter()
else
print("Error: Player cannot be found")
end
end
end
end
end
return commandmodule
Thanks for taking your time helping