Hi, i am stuck in problem that when player reset the client script in tools no longer work i have tried check if player is in workspace but it still dont work how do i fix this?
Here some part of scripts
Script 1 (got this error)
Client
local Item = script.Parent
local anim = Item.Animation
local player = game:GetService("Players").LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
if (player.Character) then
game.Workspace:WaitForChild(player.Name)
local hum = char:WaitForChild("Humanoid")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
script.Parent:WaitForChild("Requests")
local canAttack = true
local Curcombo = 0
local lastTimeClicked = tick()
local timeUntilComboResets = 1.5
local Equipping = false
local Debris = game:GetService("Debris")
local playerData = player.PlayerData
local Height = playerData.Height
local Widght = playerData.Widght
local oldws = hum.WalkSpeed
local requests = Item.Requests
local checkparam = requests.checkparam
-- animation
local Idle = hum:LoadAnimation(anim.Idle)
local Combo = {
[1] = hum:LoadAnimation(anim.Combo1),
[2] = hum:LoadAnimation(anim.Combo2),
[3] = hum:LoadAnimation(anim.Combo3),
[4] = hum:LoadAnimation(anim.Combo4),
[5] = hum:LoadAnimation(anim.Combo5),
}
local leftHand = char:FindFirstChild("LeftHand")
local RightHand = char:FindFirstChild("RightHand")
local HS = hum.HeadScale
local BDS = hum.BodyDepthScale
local BWS = hum.BodyWidthScale
local BHS = hum.BodyHeightScale
local BPS = hum.BodyProportionScale
local BTS = hum.BodyTypeScale
local function Equip()
Idle:Play()
Equipping = true
end
local function Unequip()
Idle:Stop()
Equipping = false
end
local function Attack()
--some attack script thing
end
Item.Equipped:Connect(Equip)
Item.Unequipped:Connect(Unequip)
Item.Activated:Connect(Attack)
end
ServerSide
local request = script.Parent.Requests
local checkparam = request.checkparam
local hitlist = {}
local Debris = game:GetService("Debris")
checkparam.OnServerEvent:Connect(function(player, hit)
if hit ~= nil then
if hit.Parent then
if hit.Parent ~= player.Character then
if hit.Parent:FindFirstChild("Humanoid") then
local emhum = hit.Parent:FindFirstChild("Humanoid")
for i,plr in pairs(game:GetService("Players"):GetPlayers()) do
if plr.Character then
local target = plr.Character
local dist = (player.Character.HumanoidRootPart.Position - hit.Parent.HumanoidRootPart.Position).Magnitude
if player.Character:FindFirstChild("Stun") then
player:Kick("Wow")
end
local range = 25
if dist < range then
print("hit")
local effect = script.Part.Hit:Clone()
effect.Parent = emhum.Parent:FindFirstChild("HumanoidRootPart")
local HitSound = script.Hit:Clone()
HitSound.Parent = emhum.Parent:FindFirstChild("HumanoidRootPart")
HitSound:Play()
HitSound.Stopped:Connect(function()
Debris:AddItem(HitSound, .1)
end)
for i,v in pairs(effect:GetChildren()) do
if v:IsA("ParticleEmitter") then
v:Emit(4)
end
end
local stun do
stun = Instance.new("BoolValue", emhum.Parent)
stun.Value = true
Debris:AddItem(stun, .3)
stun.Name = "Stun"
end
elseif dist > range then
player:Kick("wow")
end
end
end
end
end
end
end
end)
Script 2 ( Got this error printed and dont work after reset)
Client
local tool = script.Parent
local anim = tool.Animation
local player = game:GetService("Players").LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")
if (player.Character) then
repeat task.wait() until hum
local request = tool.Requests
local fireevent = request.fireevent
local animevent = request.fireanim
local hum = char:FindFirstChild("Humanoid")
repeat wait() hum = char:FindFirstChild("Humanoid") until hum == char:FindFirstChild("Humanoid")
local RedReversalAnim = hum:LoadAnimation(anim.RedReversal)
local function playanim()
RedReversalAnim:Play()
task.delay(RedReversalAnim.Length/1.1, function()
RedReversalAnim:AdjustSpeed(0)
end)
end
animevent.OnClientEvent:Connect(playanim)
end
Server Side
local tool = script.Parent
local anim = tool.Animation
local request = tool.Requests
local fireevent = request.fireevent
local animevent = request.fireanim
local asset = game:GetService("ReplicatedStorage").asset
local effect = asset.RedReversal
local char
local plr
local function useSkill()
local clreversal = effect:Clone()
clreversal.Parent = char
local weld do
weld = Instance.new("Weld")
weld.Parent = char:FindFirstChild("RightHand")
weld.Part0 = char:FindFirstChild("RightHand")
weld.Part1 = clreversal
weld.C0 = weld.Part0:FindFirstChild("RightGripAttachment").CFrame * CFrame.new(0,0,-0.5)
end
animevent:FireClient(plr)
end
tool.Activated:Connect(function()
useSkill()
end)
tool.Equipped:Connect(function()
char = script.Parent.Parent
plr = game:GetService("Players"):GetPlayerFromCharacter(char)
end)
Note :
Both Script is in tools
Fix :
i also got this when printing humanoid