I am making a murder mystery style game and i have a local script and a normal script called SwordScript and SwordLocalScript and 6 animations and 5 sounds on my sword
SOUNDS ANIMATIONS
1) HitSound 1) EquipAnim 2) LungeSound 2)IdleAnim3 3) OverheadSound 3)OverheadAnim2 4) SlashSound 4)SlashAnim2 5) UnsheathSound 5)ThrustAnim2 6)UnequipAnim2
My SwordScript is :
local tool = script.Parent
local speedboost = 1.25 local damage = 100 local swingtime = 1 local combowindow = .5
local handle = tool:WaitForChild("Handle") local event = tool:WaitForChild("RemoteEvent") local slashsound = handle:WaitForChild("SlashSound") local overheadsound = handle:WaitForChild("OverheadSound") local lungesound = handle:WaitForChild("LungeSound")
local lastclick = tick() local combo = 0
handle.Touched:connect(function(hit) if equipped and character and humaniod and humaniod.Health > 0 and hit and not hit: isDescendantOf(character) then local targethumaniod = hit.Parent.FindFirstChild("Humaniod") if targethumaniod and targethumaniod.Health > 0 and not hithumaniods[targethumaniod] then hithumaniods[targethumaniod] = true targethumaniod:TakeDamage(damage * combo) end end end)
tool.Activated:connect(function() local clickdelta = tick() - lastclick if clickdelta > swingtime then lastclick = tick() hithumaniods = {} if clickdelta < swingtime + combowindow then combo = (combo + 1) % 3 else combo = 0
end if player then if combo == 0 then event:FireClient(player, "RunAnimation", "SlashAnim2") slashsound:Play() elseif combo == 1 then event:FireClient(player, "RunAnimation", "ThrustAnim2") overheadsound:Play() elseif combo == 2 then event:FireClient(player, "RunAnimation", "OverheadAnim2") lungesound:Play() end end end
end)
tool.Equipped:Connect(function() equipped = true lastclick = tick() combo = 0 character = tool.Parent player = game.Players.GetPlayerFromCharacter(character) humaniod = character:FindFirstChild("humaniod") if humaniod then humaniod.WalkSpeed = humaniod.WalkSpeed * speedboost else character = nil end end)
tool.Unequipped:connect(function() equipped = false if humaniod then humaniod.WalkSpeed = humaniod.WalkSpeed / speedboost end character = nil humaniod = nil end)
And my LocalSwordScript is :
local tool = script.Parent
local event = tool:WaitForChild("RemoteEvent")
event.OnClientEvent:connect(function(...) local tuple = (...) if tuple[1] == "RunAnimation" then local anim = tool:FindFirstChild(tuple[2]) if anim and humaniod then local loadedanim = humaniod:LoadAnimation(anim) if loadedanim then loadanim:Play() if themouse then themouse.Icon = "rbxasset://textures\GunWaitCursor.png" wait(1) themouse.Icon = "rbxasset://textures\GunCursor.png" end end end end end)
tool.Equipped:Connect(Function(mouse) -- Here Is The Main Problem(line 31)
themouse = mouse
humaniod = tool.Parent:FindFirstChild("Humaniod")
if humaniod then
local anim = tool:FindFirstChild("IdleAnim3")
if anim and humaniod then
if loadedildeanim then
loadedidleanim:Stop()
end
loadedidleanim = humaniod:LoadAnimation(anim)
if loadedidleanim then
loadedidleanim:Play()
end
end
local anim = tool:FindFirstChild("EquipAnim")
if anim and humaniod then
local loadedanim = humaniod:LoadAnimation(anim)
if loadedanim then
loadanim:Play()
end
end
end
if themouse then
themouse.Icon = "rbxasset://textures\GunCursor.png"
end
tool.Uneqquipped:connect(function() if loadedidleanim then loadedildeanim:Stop() end end)
I'm not sure if the SwordScript has a problem but the SwordLocalScript Does If anyone Can, the sword for the moment is in the starting tools PS : I have tried adding a bracket but then the rest of the script messes up