For some reason, in my output everytime i reset the character and respawn, it comes up with the error “Humanoid is not a valid member of model” and it breaks the character.
Heres the script:
local cam = game.Workspace.CurrentCamera
local player = players.LocalPlayer
local m = player:GetMouse()
m.Icon = "http://www.roblox.com/asset/?id=569021388" -- replaces mouse icon
local character = player.Character or player.CharacterAdded:wait()
local human = character.Humanoid
local humanoidpart = character.HumanoidRootPart
I fixed the script. Not sure if this was the issue for however it should work? You missed some from local player
local cam = game.Workspace.CurrentCamera
local player = game.Players.LocalPlayer
local m = player:GetMouse()
m.Icon = "http://www.roblox.com/asset/?id=569021388" -- replaces mouse icon
local character = player.Character or player.CharacterAdded:wait()
local human = character.Humanoid
local humanoidpart = character.HumanoidRootPart
the knife clients script causes this error and doesn’t respawn the character (this is a local script)
local Player = game:GetService("Players").LocalPlayer
local Tool = script.Parent
local Remote = Tool:WaitForChild("Remote")
local Handle = Tool:WaitForChild("Handle")
local char = Tool.Parent
repeat wait() until game:GetService("Players").LocalPlayer.Character ~= nil
local runService = game:GetService("RunService")
local input = game:GetService("UserInputService")
local players = game:GetService("Players")
local player = players.LocalPlayer
local character = player.Character or player.CharacterAdded:wait()
local human = character.Humanoid
local UIS = game:GetService("UserInputService")
local Mouse = Player:GetMouse()
local Tool = script.Parent
local Remote = Tool:WaitForChild("Remote")
local Tracks = {}
local InputType = Enum.UserInputType
local BeganConnection, EndedConnection
function playAnimation(animName, ...)
if Tracks[animName] then
Tracks[animName]:Play()
else
local anim = Tool:FindFirstChild(animName)
if anim and Tool.Parent and Tool.Parent:FindFirstChild("Humanoid") then
Tracks[animName] = Tool.Parent.Humanoid:LoadAnimation(anim)
playAnimation(animName, ...)
end
end
end
function stopAnimation(animName)
if Tracks[animName] then
Tracks[animName]:Stop()
end
end
function inputBegan(input)
if input.UserInputType == InputType.MouseButton1 then
Remote:FireServer("LeftDown", Mouse.Hit.p)
end
end
function inputEnded(input)
if input.UserInputType == InputType.MouseButton1 then
Remote:FireServer("LeftUp")
end
end
function onRemote(func, ...)
if func == "PlayAnimation" then
playAnimation(...)
elseif func == "StopAnimation" then
stopAnimation(...)
end
end
function onEquip()
BeganConnection = UIS.InputBegan:connect(inputBegan)
EndedConnection = UIS.InputEnded:connect(inputEnded)
end
function onUnequip()
if BeganConnection then
BeganConnection:disconnect()
BeganConnection = nil
end
if EndedConnection then
EndedConnection:disconnect()
EndedConnection = nil
end
end
Tool.Equipped:connect(onEquip)
Tool.Unequipped:connect(onUnequip)
Remote.OnClientEvent:connect(onRemote)